@kognai/orchestrator-core 0.1.1 → 0.1.2

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.
package/dist/index.d.ts CHANGED
@@ -61,4 +61,5 @@ export * from './lib/citizen-score-contract';
61
61
  export * from './lib/citizen-score-registry';
62
62
  export * from './lib/sovereign-agent-factory';
63
63
  export { runOrchestrator } from './lib/orchestrate-engine';
64
+ export type { OrchestratorConfig, SpawnGate, SpawnGateResult, AgentSpawnSpec, } from './lib/orchestrate-engine';
64
65
  export { runSprintCycle, SprintRunnerOpts } from './lib/sprint-runner-engine';
@@ -21,5 +21,27 @@
21
21
  * Flow: CEO plans → MiniMax codes → Dual Supervisor review (DeepSeek + Haiku)
22
22
  * → CEO resolves conflicts → CTO analyzes → CMO reports → CEO daily report
23
23
  */
24
- declare function main(): Promise<void>;
24
+ export interface AgentSpawnSpec {
25
+ name: string;
26
+ role: string;
27
+ llm: 'minimax' | 'anthropic';
28
+ trigger: string;
29
+ prompt_summary: string;
30
+ }
31
+ export interface SpawnGateResult {
32
+ approved: boolean;
33
+ /** Human-readable reason when not approved (rejected or pending). */
34
+ rejection_reason?: string;
35
+ /** True when the spawn is suspended awaiting an out-of-band (e.g. human) approval. */
36
+ pending_approval?: boolean;
37
+ /** Optional one-line audit string logged on an approved decision. */
38
+ audit?: string;
39
+ }
40
+ export type SpawnGate = (spec: AgentSpawnSpec) => SpawnGateResult;
41
+ /** TICKET-225: engine config supplied by the consuming template. */
42
+ export interface OrchestratorConfig {
43
+ /** Optional template-carried spawn governance gate (Kognai → SAF). */
44
+ spawnGate?: SpawnGate;
45
+ }
46
+ declare function main(config?: OrchestratorConfig): Promise<void>;
25
47
  export { main as runOrchestrator };
@@ -1518,9 +1518,31 @@ Rules: Be specific — reference task IDs, rejection counts, concrete patterns.
1518
1518
  }
1519
1519
  }
1520
1520
  }
1521
- // ===== Agent Creator (creates new agents from CEO-approved CTO proposals) =====
1522
1521
  class AgentCreator {
1522
+ spawnGate;
1523
+ constructor(spawnGate) {
1524
+ this.spawnGate = spawnGate;
1525
+ }
1523
1526
  createAgent(spec) {
1527
+ // TICKET-225 — template-carried spawn governance. If the consuming template
1528
+ // supplied a SpawnGate (Kognai wires SAF here), consult it BEFORE creating
1529
+ // anything on disk. Approval/rejection only; the citizenship logic below is
1530
+ // unchanged (its extraction is tracked separately as TICKET-226).
1531
+ if (this.spawnGate) {
1532
+ const decision = this.spawnGate(spec);
1533
+ if (!decision.approved) {
1534
+ const why = decision.rejection_reason ? `: ${decision.rejection_reason}` : '';
1535
+ if (decision.pending_approval) {
1536
+ log(c.yellow, ` ⏸ Spawn of ${spec.name} pending approval${why}`);
1537
+ }
1538
+ else {
1539
+ log(c.red, ` ✗ Spawn of ${spec.name} blocked${why}`);
1540
+ }
1541
+ return '';
1542
+ }
1543
+ if (decision.audit)
1544
+ log(c.gray, ` ✓ ${decision.audit}`);
1545
+ }
1524
1546
  const agentDir = `./agents/${spec.name}`;
1525
1547
  (0, fs_1.mkdirSync)(agentDir, { recursive: true });
1526
1548
  // Founder rule 2026-05-27: every spawned agent is born as a Kognai
@@ -2939,6 +2961,7 @@ ${originalContent}
2939
2961
  }
2940
2962
  // ===== Orchestrator (Dynamic Agent Pipeline) =====
2941
2963
  class Orchestrator {
2964
+ spawnGate;
2942
2965
  ceo;
2943
2966
  cto;
2944
2967
  supervisor;
@@ -3046,7 +3069,10 @@ class Orchestrator {
3046
3069
  (0, fs_1.writeFileSync)(sprintFile, JSON.stringify(sprintRaw, null, 2));
3047
3070
  log(c.green, ` [inject] Added ${injected} split sub-tasks to ${sprintFile} (in-memory + on-disk)`);
3048
3071
  }
3049
- constructor() {
3072
+ // TICKET-225: optional template-supplied spawn governance gate, threaded
3073
+ // from runOrchestrator(config) down to AgentCreator. Undefined = no gate.
3074
+ constructor(spawnGate) {
3075
+ this.spawnGate = spawnGate;
3050
3076
  log(c.bold, '\n╔══════════════════════════════════════════════════════════╗');
3051
3077
  log(c.bold, '║ Kognai Swarm Orchestrator v2.17 — V17 Architecture ║');
3052
3078
  log(c.bold, '║ Local-first · ClawRouter cloud · DeepSeek reviews ║');
@@ -4163,7 +4189,7 @@ ONLY output the JSON array. No markdown, no explanation.`;
4163
4189
  // Persist CEO decisions for CTO feedback loop + approved proposals tracking
4164
4190
  persistCEODecisions(ctoDecisions, ctoReport);
4165
4191
  // Handle approved new_agent proposals
4166
- const agentCreator = new AgentCreator();
4192
+ const agentCreator = new AgentCreator(this.spawnGate);
4167
4193
  for (const proposal of ctoReport.proposals) {
4168
4194
  if (proposal.category === 'new_agent' && proposal.agent_spec) {
4169
4195
  // Check if CEO approved this specific proposal
@@ -4414,8 +4440,7 @@ async function postSprintSmokeTest() {
4414
4440
  // Disabled — Invoica-specific endpoints (health/invoices/settlements) not applicable to Kognai
4415
4441
  // Removed Sprint 205: was always returning HTTP 404 + flooding Telegram with false alerts
4416
4442
  }
4417
- // ===== Main Entry =====
4418
- async function main() {
4443
+ async function main(config = {}) {
4419
4444
  // S67-005: Startup env check (OMEL AMD-13: via CredentialVault — hasSecret never logs value)
4420
4445
  if (!credential_vault_1.credentialVault.hasSecret('ANTHROPIC_API_KEY', 'orchestrator')) {
4421
4446
  log(c.yellow, '⚠ ANTHROPIC_API_KEY not set — Anthropic CEO + Sup2 Haiku will be unavailable.');
@@ -4425,7 +4450,7 @@ async function main() {
4425
4450
  log(c.yellow, '⚠ MINIMAX_API_KEY not set — cloud-code tasks will fail.');
4426
4451
  }
4427
4452
  try {
4428
- const orchestrator = new Orchestrator();
4453
+ const orchestrator = new Orchestrator(config.spawnGate);
4429
4454
  await orchestrator.run();
4430
4455
  }
4431
4456
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kognai/orchestrator-core",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Kognai sovereign orchestrator — core engine (template-agnostic). Shared by all products (Kognai/coding, Voxight/market-intel, Invoica/fin-compliance); each supplies only its template. Replaces per-repo forks of orchestrate-agents-v2 / sprint-runner / lib.",
5
5
  "license": "MIT",
6
6
  "author": "SkinGem",