@principles/host-runtime 0.4.0 → 0.6.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.
@@ -21,7 +21,7 @@
21
21
  * env getter. Everything else is the existing production path.
22
22
  */
23
23
  import { createHash } from 'node:crypto';
24
- import { createRuntimeStateHandle, InternalizationOrchestrator, DreamerRunner, PhilosopherRunner, ScribeRunner, ArtificerRunner, buildArtificerHostSemanticContext, EvaluatorRunner, RolloutReviewerRunner, DefaultDreamerValidator, DefaultPhilosopherValidator, DefaultScribeValidator, DefaultArtificerValidator, DefaultEvaluatorValidator, DefaultRolloutReviewerValidator, PiAiRuntimeAdapter, L2AgentLoopAdapter, buildL2PrincipleReaderFromLedger, OpenClawCliRuntimeAdapter, storeEmitter, createProductionGateDeps, resolveRuntimeConfigFromPdConfig, resolveRuntimeConfigForAgent, AGENT_NAME_FOR_TASK_KIND, isRuntimeConfigError, computeConsumerDecision, FULL_CHAIN_CONSUMER_RUNNER_KINDS, DEFAULT_CONSUMER_RUNNER_KINDS, InternalizationQueueReadModel, MVP_CORE_TASK_KINDS, SqliteConnection, SqliteReconciliationCursorStore, SUCCEEDED_TRANSITIONS_SCOPE,
24
+ import { createRuntimeStateHandle, InternalizationOrchestrator, DreamerRunner, PhilosopherRunner, ScribeRunner, ArtificerRunner, buildArtificerHostSemanticContext, EvaluatorRunner, RolloutReviewerRunner, DefaultDreamerValidator, DefaultPhilosopherValidator, DefaultScribeValidator, DefaultArtificerValidator, DefaultEvaluatorValidator, DefaultRolloutReviewerValidator, PiAiRuntimeAdapter, L2AgentLoopAdapter, ArtificerL2Adapter, buildL2PrincipleReaderFromLedger, OpenClawCliRuntimeAdapter, storeEmitter, createProductionGateDeps, resolveRuntimeConfigFromPdConfig, resolveRuntimeConfigForAgent, AGENT_NAME_FOR_TASK_KIND, isRuntimeConfigError, computeConsumerDecision, FULL_CHAIN_CONSUMER_RUNNER_KINDS, DEFAULT_CONSUMER_RUNNER_KINDS, InternalizationQueueReadModel, MVP_CORE_TASK_KINDS, SqliteConnection, SqliteReconciliationCursorStore, SUCCEEDED_TRANSITIONS_SCOPE,
25
25
  // PRI-714: resolve outputLanguage from the same effective config the
26
26
  // runners already receive (EP-07: canonical resolved value, not raw input).
27
27
  resolveOutputLanguage, } from '@principles/core/runtime-v2';
@@ -316,7 +316,35 @@ export async function runInternalizationConsumerCycle(workspaceDir, ports) {
316
316
  // PRI-419: when l2_dreamer flag is on AND this is a dreamer task, route
317
317
  // through the L2 multi-turn agent loop. Non-dreamer runners always use PiAi.
318
318
  const l2Flag = loadFeatureFlagFromConfig(workspaceDir, 'l2_dreamer');
319
- if (l2Flag.enabled && wakeResult.taskKind === 'dreamer') {
319
+ // PRI-758: code_rule Artificer tasks on code_tool_hook channel route
320
+ // through the L2 multi-turn agent loop (write→validate→replay→submit_rulecode)
321
+ // so the model can self-iterate before submitting. Honors the
322
+ // code_rule_capability emergency-disable flag (PR #1661 CodeRabbit P1).
323
+ const codeRuleFlag = loadFeatureFlagFromConfig(workspaceDir, 'code_rule_capability');
324
+ if (wakeResult.taskKind === 'artificer'
325
+ && taskRuntimeKind === 'pi-ai'
326
+ && codeRuleFlag.enabled) {
327
+ adapter = new ArtificerL2Adapter({
328
+ // Profile readiness check guarantees these are non-undefined for
329
+ // pi-ai runtime kind (validatePdLocalProfile enforces provider/model/apiKeyEnv).
330
+ provider: taskRuntimeConfig.provider ?? '',
331
+ model: taskRuntimeConfig.model ?? '',
332
+ apiKeyEnv: taskRuntimeConfig.apiKeyEnv ?? '',
333
+ baseUrl: taskRuntimeConfig.baseUrl,
334
+ // PRI-758 CodeRabbit P1: pass toolSemantics + projectDir so the L2
335
+ // replay uses production-identical gate context (not baseline).
336
+ gateDeps: createProductionGateDeps({
337
+ toolSemantics: ports.toolSemantics,
338
+ projectDir: workspaceDir,
339
+ }),
340
+ validator: new DefaultArtificerValidator(),
341
+ totalBudgetMs: taskRuntimeConfig.timeoutMs,
342
+ // PRI-758 CodeRabbit P2: forward maxTokens + systemPrompt from profile.
343
+ ...(taskRuntimeConfig.maxTokens !== undefined ? { maxTokens: taskRuntimeConfig.maxTokens } : {}),
344
+ ...(taskRuntimeConfig.systemPrompt ? { systemPrompt: taskRuntimeConfig.systemPrompt } : {}),
345
+ });
346
+ }
347
+ else if (l2Flag.enabled && wakeResult.taskKind === 'dreamer') {
320
348
  const stateDir = `${workspaceDir}/.state`;
321
349
  const principleReader = buildL2PrincipleReaderFromLedger(loadLedger(stateDir), {
322
350
  logger: { warn: (msg) => logger.warn(msg) },
@@ -356,6 +384,9 @@ export async function runInternalizationConsumerCycle(workspaceDir, ports) {
356
384
  timeoutMs: taskRuntimeConfig.timeoutMs,
357
385
  baseUrl: taskRuntimeConfig.baseUrl,
358
386
  workspace: workspaceDir,
387
+ // PRI-758: profile reasoning level rides to pi-ai (thinking control
388
+ // for always-thinking zai models, e.g. glm-5.3-flash).
389
+ ...(taskRuntimeConfig.reasoning !== undefined ? { reasoning: taskRuntimeConfig.reasoning } : {}),
359
390
  // PRI-633: profile systemPrompt rides as the append layer.
360
391
  ...(taskRuntimeConfig.systemPrompt ? { systemPrompt: taskRuntimeConfig.systemPrompt } : {}),
361
392
  });
package/dist/pd-config.js CHANGED
@@ -86,7 +86,7 @@ export function loadPdConfigForPlugin(workspaceDir) {
86
86
  };
87
87
  }
88
88
  const effective = computeEffectivePdConfig(validation.value);
89
- return { ok: true, effective, source: 'user_config', configPath, warnings: effective.warnings, errors: [] };
89
+ return { ok: true, effective, source: 'user_config', configPath, warnings: [...effective.warnings, ...validation.warnings], errors: [] };
90
90
  }
91
91
  export function loadFeatureFlagFromConfig(workspaceDir, flagId, logger) {
92
92
  const result = loadPdConfigForPlugin(workspaceDir);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@principles/host-runtime",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "description": "Shared host-neutral orchestration for Principles Disciple MVP-Core hook paths.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",