@wrongstack/core 0.298.3 → 0.300.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 (70) hide show
  1. package/dist/chronicle/index.js +4 -1
  2. package/dist/coordination/agents/index.js +4 -1
  3. package/dist/coordination/director.d.ts +8 -0
  4. package/dist/coordination/fleet-manager.d.ts +48 -3
  5. package/dist/coordination/ifleet-manager.d.ts +2 -0
  6. package/dist/coordination/index.js +127 -24
  7. package/dist/coordination/multi-agent-coordinator.d.ts +1 -0
  8. package/dist/core/fallback-model.d.ts +48 -0
  9. package/dist/core/index.d.ts +3 -2
  10. package/dist/core/index.js +288 -34
  11. package/dist/core/instruction-template.d.ts +80 -0
  12. package/dist/core/system-prompt-blocks.d.ts +10 -1
  13. package/dist/core/system-prompt-builder.d.ts +35 -1
  14. package/dist/defaults/index.js +358 -117
  15. package/dist/design/index.js +4 -1
  16. package/dist/execution/autonomy-brain.d.ts +7 -0
  17. package/dist/execution/council-brain.d.ts +17 -2
  18. package/dist/execution/council-orchestrator.d.ts +23 -4
  19. package/dist/execution/council-personas.d.ts +10 -0
  20. package/dist/execution/council-prompts.d.ts +12 -1
  21. package/dist/execution/index.d.ts +1 -1
  22. package/dist/execution/index.js +412 -145
  23. package/dist/fleet-notifier.d.ts +9 -2
  24. package/dist/goal/index.js +4 -1
  25. package/dist/hooks/index.js +140 -10
  26. package/dist/hq/exposure.d.ts +0 -11
  27. package/dist/hq/index.js +34 -8
  28. package/dist/hq/protocol/client.d.ts +14 -1
  29. package/dist/hq/protocol/fleet.d.ts +22 -0
  30. package/dist/hq/protocol.js +12 -1
  31. package/dist/index.d.ts +2 -1
  32. package/dist/index.js +1718 -753
  33. package/dist/infrastructure/index.js +50 -2
  34. package/dist/infrastructure/mcp-servers.d.ts +35 -0
  35. package/dist/kernel/events/brain-events.d.ts +9 -0
  36. package/dist/kernel/events/provider-events.d.ts +49 -2
  37. package/dist/kernel/events/sdd-events.d.ts +2 -0
  38. package/dist/models/index.js +1 -1
  39. package/dist/plugin/api.d.ts +6 -0
  40. package/dist/plugin/config.d.ts +55 -0
  41. package/dist/plugin/index.d.ts +1 -1
  42. package/dist/plugin/index.js +138 -22
  43. package/dist/security/index.d.ts +1 -1
  44. package/dist/security/index.js +157 -42
  45. package/dist/security/permission-helpers.d.ts +23 -6
  46. package/dist/security/permission-policy.d.ts +16 -0
  47. package/dist/security/totp.d.ts +14 -0
  48. package/dist/storage/director-state.d.ts +7 -0
  49. package/dist/storage/index.js +46 -9
  50. package/dist/tools/council-tool.d.ts +1 -1
  51. package/dist/tools/fallback-system-config-view-tool.d.ts +1 -1
  52. package/dist/tools/index.js +449 -112
  53. package/dist/types/config/skills-fleet-brain.d.ts +4 -2
  54. package/dist/types/config/tools.d.ts +99 -0
  55. package/dist/types/council.d.ts +11 -0
  56. package/dist/types/index.d.ts +3 -2
  57. package/dist/types/index.js +3 -3
  58. package/dist/types/multi-agent.d.ts +10 -0
  59. package/dist/types/one-shot-llm.d.ts +31 -3
  60. package/dist/types/plugin.d.ts +28 -0
  61. package/dist/types/session.d.ts +5 -1
  62. package/dist/utils/index.js +4 -1
  63. package/dist/utils/wstack-paths.d.ts +2 -0
  64. package/dist/worktree/index.js +47 -25
  65. package/dist/worktree/worktree-manager.d.ts +16 -10
  66. package/instructions/coordination/subagent-baseline.md +8 -0
  67. package/instructions/system-lite.md +83 -3
  68. package/instructions/system-pro.md +286 -97
  69. package/instructions/system.md +236 -85
  70. package/package.json +3 -3
@@ -6,6 +6,7 @@ import type { SkillLoader } from '../types/skill.js';
6
6
  import type { BuildContext, ModelCapabilities, SystemPromptBuilder, SystemPromptRegions } from '../types/system-prompt.js';
7
7
  import type { SystemPromptContributor } from '../types/system-prompt-contributor.js';
8
8
  import { type InstructionBundle, type InstructionBundlePaths } from './instruction-bundle.js';
9
+ import { type InstructionTemplateContext } from './instruction-template.js';
9
10
  export { effectiveShell, shellGuidanceBlock, type EffectiveShell } from './system-prompt-shell.js';
10
11
  export declare const LAYER_1_IDENTITY: string;
11
12
  /**
@@ -20,8 +21,16 @@ export declare const LAYER_1_IDENTITY: string;
20
21
  *
21
22
  * Bundled, profile-global and explicitly-passed override files are user-owned
22
23
  * and keep full replacement semantics.
24
+ *
25
+ * `tplCtx` renders the conditional blocks in the markdown against the live tool
26
+ * set (see `instruction-template.ts`), so guidance for tools the current
27
+ * request never registered stays out of the prompt entirely. The two layers are
28
+ * rendered **separately** rather than after concatenation: an unclosed
29
+ * `ws:if` in the repo-committed file must not be able to swallow the genuine
30
+ * identity that precedes it. Omitting `tplCtx` keeps the full text, which is
31
+ * what embedders reading the bundled prompt directly expect.
23
32
  */
24
- export declare function buildIdentityLayer(identity: string | undefined, source: 'bundled' | 'global' | 'project' | 'file' | undefined): string;
33
+ export declare function buildIdentityLayer(identity: string | undefined, source: 'bundled' | 'global' | 'project' | 'file' | undefined, tplCtx?: InstructionTemplateContext | undefined): string;
25
34
  export type { SystemBlockSource } from './system-prompt-blocks.js';
26
35
  export { SYSTEM_BLOCK_SOURCE } from './system-prompt-blocks.js';
27
36
  export interface DefaultSystemPromptBuilderOptions {
@@ -127,6 +136,13 @@ export declare class DefaultSystemPromptBuilder implements SystemPromptBuilder {
127
136
  /** Cached full buildToolUsage output — keyed by tools array ref + agents fingerprint + tier. */
128
137
  private _toolsUsageCache?;
129
138
  private _instructionBundle?;
139
+ /**
140
+ * Cached rendered identity layer. Keyed the same way as `_toolsUsageCache`:
141
+ * the ToolRegistry snapshot keeps the array reference stable until a registry
142
+ * mutation, so reference equality is a sound key for "the tool set did not
143
+ * change".
144
+ */
145
+ private _identityCache?;
130
146
  constructor(opts?: DefaultSystemPromptBuilderOptions);
131
147
  /**
132
148
  * Normalizes `tokenSavingMode` to a boolean for backward-compatible boolean checks.
@@ -152,6 +168,24 @@ export declare class DefaultSystemPromptBuilder implements SystemPromptBuilder {
152
168
  private toolDescLimit;
153
169
  build(ctx: BuildContext): Promise<TextBlock[]>;
154
170
  buildRegions(ctx: BuildContext): Promise<SystemPromptRegions>;
171
+ /**
172
+ * The view of the live request that the markdown conditionals are evaluated
173
+ * against: which tools can actually be called, the effective token-saving
174
+ * tier, and whether this prompt is for a subagent.
175
+ */
176
+ private templateContext;
177
+ /**
178
+ * Render the identity layer, memoized on the tool set / tier / role triple.
179
+ *
180
+ * The rendering itself is a couple of regex passes over ~40 KB, which is
181
+ * cheap but happens on every turn; the tool set is stable for the life of a
182
+ * session in the normal case, so the cache turns it into a one-off.
183
+ *
184
+ * This does not cost prompt-cache hits: in the wire format the `tools` array
185
+ * precedes `system`, so any registry mutation already invalidates the
186
+ * provider's prefix cache before the identity block is reached.
187
+ */
188
+ private buildIdentity;
155
189
  private instructions;
156
190
  /**
157
191
  * Cached plan content keyed by (planPath, mtimeMs). The plan is read