@xemahq/kernel-contracts 0.3.5 → 0.3.6

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 (48) hide show
  1. package/dist/agent-composition/index.d.ts +1 -0
  2. package/dist/agent-composition/index.d.ts.map +1 -1
  3. package/dist/agent-composition/index.js +1 -0
  4. package/dist/agent-composition/index.js.map +1 -1
  5. package/dist/agent-composition/lib/composition.d.ts +3 -10
  6. package/dist/agent-composition/lib/composition.d.ts.map +1 -1
  7. package/dist/agent-composition/lib/composition.js.map +1 -1
  8. package/dist/agent-composition/lib/invocation-overlay.d.ts +17 -0
  9. package/dist/agent-composition/lib/invocation-overlay.d.ts.map +1 -0
  10. package/dist/agent-composition/lib/invocation-overlay.js +3 -0
  11. package/dist/agent-composition/lib/invocation-overlay.js.map +1 -0
  12. package/dist/agent-permission/index.d.ts +2 -0
  13. package/dist/agent-permission/index.d.ts.map +1 -0
  14. package/dist/agent-permission/index.js +18 -0
  15. package/dist/agent-permission/index.js.map +1 -0
  16. package/dist/agent-permission/lib/permission-map.d.ts +6 -0
  17. package/dist/agent-permission/lib/permission-map.d.ts.map +1 -0
  18. package/dist/agent-permission/lib/permission-map.js +27 -0
  19. package/dist/agent-permission/lib/permission-map.js.map +1 -0
  20. package/dist/agent-workspace/awp-spec.json +1 -1
  21. package/dist/agent-workspace/lib/agent-tool-defaults.d.ts +2 -5
  22. package/dist/agent-workspace/lib/agent-tool-defaults.d.ts.map +1 -1
  23. package/dist/agent-workspace/lib/agent-tool-defaults.js +5 -25
  24. package/dist/agent-workspace/lib/agent-tool-defaults.js.map +1 -1
  25. package/dist/reference-resolution/index.d.ts +2 -0
  26. package/dist/reference-resolution/index.d.ts.map +1 -0
  27. package/dist/reference-resolution/index.js +18 -0
  28. package/dist/reference-resolution/index.js.map +1 -0
  29. package/dist/reference-resolution/lib/reference-resolution.d.ts +40 -0
  30. package/dist/reference-resolution/lib/reference-resolution.d.ts.map +1 -0
  31. package/dist/reference-resolution/lib/reference-resolution.js +42 -0
  32. package/dist/reference-resolution/lib/reference-resolution.js.map +1 -0
  33. package/dist/workflow/lib/compiled-workspace-manifest.d.ts +1 -1
  34. package/dist/workflow/lib/compiled-workspace-manifest.d.ts.map +1 -1
  35. package/dist/workflow/lib/model-ref.d.ts +18 -8
  36. package/dist/workflow/lib/model-ref.d.ts.map +1 -1
  37. package/dist/workflow/lib/model-ref.js.map +1 -1
  38. package/package.json +1 -1
  39. package/src/agent-composition/index.ts +1 -0
  40. package/src/agent-composition/lib/composition.ts +11 -57
  41. package/src/agent-composition/lib/invocation-overlay.ts +75 -0
  42. package/src/agent-permission/index.ts +12 -0
  43. package/src/agent-permission/lib/permission-map.ts +71 -0
  44. package/src/agent-workspace/lib/agent-tool-defaults.ts +20 -56
  45. package/src/reference-resolution/index.ts +10 -0
  46. package/src/reference-resolution/lib/reference-resolution.ts +175 -0
  47. package/src/workflow/lib/compiled-workspace-manifest.ts +1 -1
  48. package/src/workflow/lib/model-ref.ts +81 -28
@@ -22,7 +22,7 @@
22
22
 
23
23
  import { z } from 'zod';
24
24
 
25
- import type { PermissionMap } from '../../agent-workspace/lib/agent-tool-defaults';
25
+ import type { PermissionMap } from '../../agent-permission';
26
26
 
27
27
  /**
28
28
  * LLM-routing tier. The SINGLE source of truth for the closed set
@@ -70,27 +70,68 @@ export enum ModelRefKind {
70
70
  STRATEGY = 'strategy',
71
71
  }
72
72
 
73
+ /**
74
+ * Model generation / sampling options — the closed set of knobs an author
75
+ * MAY set on a model reference.
76
+ *
77
+ * **No platform-side defaults (hard rule).** Every field is optional and
78
+ * Xema injects NO default for any of them. An unset field is passed through
79
+ * as ABSENT so the engine/provider applies its own default — never
80
+ * materialise a value here, in a DTO, a Zod `.default()`, a seeder, or a
81
+ * `?? <n>` fallback. Forward a field to the provider only when it is
82
+ * explicitly defined (the `request.x !== undefined` pattern).
83
+ *
84
+ * Spread (via `extends`) by both {@link ConcreteModelRef} and
85
+ * {@link StrategyModelRef} so every override slot in the platform inherits
86
+ * new options for free — one fragment, no parallel field, no per-slot
87
+ * restatement (the `ModelRef` / `PermissionMap` reuse pattern).
88
+ */
89
+ export interface ModelOptions {
90
+ /** Sampling temperature. Unset = engine default (NOT 0). */
91
+ readonly temperature?: number;
92
+ /** Nucleus sampling top-p. Unset = engine default. */
93
+ readonly topP?: number;
94
+ /** Max output tokens for the completion. Unset = engine default. */
95
+ readonly maxTokens?: number;
96
+ /** Stop sequences. Unset = engine default. */
97
+ readonly stop?: readonly string[];
98
+ /** Presence penalty. Unset = engine default. */
99
+ readonly presencePenalty?: number;
100
+ /** Frequency penalty. Unset = engine default. */
101
+ readonly frequencyPenalty?: number;
102
+ /**
103
+ * Reasoning effort, provider-specific (e.g. `low`/`medium`/`high`).
104
+ * Free-form string because the accepted set differs per provider.
105
+ * Unset = engine default.
106
+ */
107
+ readonly reasoningEffort?: string;
108
+ /** Extended-thinking token budget, provider-specific. Unset = engine default. */
109
+ readonly thinkingBudget?: number;
110
+ }
111
+
73
112
  /**
74
113
  * Pin to a specific (modelId, providerSlug). The provider slug is
75
114
  * optional only when the modelId is globally unique across credentialed
76
115
  * providers for the org — when ambiguous, the resolver returns 400.
116
+ *
117
+ * Carries the optional {@link ModelOptions} sampling knobs (temperature,
118
+ * topP, maxTokens, …) — all pass-through-only, no platform default.
77
119
  */
78
- export interface ConcreteModelRef {
120
+ export interface ConcreteModelRef extends ModelOptions {
79
121
  readonly kind: ModelRefKind.CONCRETE;
80
122
  readonly modelId: string;
81
123
  readonly providerSlug?: string;
82
- readonly temperature?: number;
83
124
  }
84
125
 
85
126
  /**
86
127
  * Route through the existing `ModelStrategy` cascade for a given
87
128
  * `ModelClass`. The bound model can change without invalidating the
88
- * reference (lazy resolution).
129
+ * reference (lazy resolution). Carries the optional {@link ModelOptions}
130
+ * sampling knobs — all pass-through-only, no platform default.
89
131
  */
90
- export interface StrategyModelRef {
132
+ export interface StrategyModelRef extends ModelOptions {
91
133
  readonly kind: ModelRefKind.STRATEGY;
92
134
  readonly modelClass: ModelClass;
93
- readonly temperature?: number;
94
135
  }
95
136
 
96
137
  export type ModelRef = ConcreteModelRef | StrategyModelRef;
@@ -103,35 +144,47 @@ export function isStrategyModelRef(ref: ModelRef): ref is StrategyModelRef {
103
144
  return ref.kind === ModelRefKind.STRATEGY;
104
145
  }
105
146
 
147
+ /**
148
+ * The INVOCATION-overlay fragment shared by EVERY "agent node" shape — the
149
+ * genuinely-identical trio that specializes a referenced agent WITHOUT
150
+ * authoring a new definition. Single declaration site (the
151
+ * `ModelRef`/`PermissionMap` reuse pattern): `CompositionNode`,
152
+ * `SubAgentBinding`, the compiled manifest agent block, and the typed
153
+ * workflow/session invocation overlays all `extends` this — the trio is
154
+ * never restated per shape.
155
+ *
156
+ * Identity floors always win (add-or-restrict, never widen):
157
+ * - `modelOverride` — OVERRIDE: which model + how it samples
158
+ * ({@link ModelOptions}). Resolver reads `modelOverride.temperature`
159
+ * etc. to stamp sampling; omitted ⇒ the Model Resolution Matrix decides.
160
+ * - `instructions` — ADDITIVE: a prompt fragment layered AFTER the base
161
+ * agent's `systemPrompt` (composite order: base prompt THEN this; the
162
+ * platform `system-overlay.md` is injected LATER by the runtime).
163
+ * Absent/blank ⇒ base prompt passes through unchanged (never an empty
164
+ * append).
165
+ * - `permission` — RESTRICT-merge: a partial `PermissionMap`
166
+ * deep-merged per top-level key OVER the base agent's authored
167
+ * permission, BEFORE the system tiers run (`resolveAgentPermissions`).
168
+ * A present key replaces the base's value for that key; absent keys
169
+ * fall through. Omitted ⇒ base permissions unchanged. May only narrow.
170
+ */
171
+ export interface NodeOverlayFragment {
172
+ readonly modelOverride?: ModelRef;
173
+ readonly instructions?: string;
174
+ readonly permission?: PermissionMap;
175
+ }
176
+
106
177
  /**
107
178
  * A runtime attachment: "while this session/step runs, mount agent
108
- * `slug` as a delegate available to the primary, optionally with a
109
- * model override."
179
+ * `slug` as a delegate available to the primary, optionally specialized
180
+ * via the {@link NodeOverlayFragment} trio (model / instructions / permission)."
110
181
  *
111
182
  * Intrinsic delegates (those declared in the primary's own source
112
183
  * manifest under `permission.task.<slug>: allow`) are the floor — they
113
184
  * are always mounted and cannot be removed by any binding layer. A
114
- * binding on an intrinsic slug refines its model only.
185
+ * binding on an intrinsic slug refines its overlay only.
115
186
  */
116
- export interface SubAgentBinding {
187
+ export interface SubAgentBinding extends NodeOverlayFragment {
117
188
  readonly slug: string;
118
189
  readonly alias?: string;
119
- readonly modelOverride?: ModelRef;
120
- /**
121
- * Optional node-level instructions carried through from the authored
122
- * manifest's `spec.agent.subAgents[].instructions` (WS5 Phase B). A prompt
123
- * fragment the runtime layers ONTO the referenced base agent's intrinsic
124
- * system prompt — the `base agent slug + instructions` lever. Absent = the
125
- * base agent's prompt passes through unchanged.
126
- */
127
- readonly instructions?: string;
128
- /**
129
- * Optional node-level permission override carried through from
130
- * `spec.agent.subAgents[].permission`. Deep-merged (per top-level key)
131
- * over the referenced base agent's authored permission before the system
132
- * tiers run — the lever that turns a generic base agent into a bounded
133
- * delegate (read-only, scoped `task` allowlist) without a new definition.
134
- * Absent = the base agent's permissions pass through unchanged.
135
- */
136
- readonly permission?: PermissionMap;
137
190
  }