@kognai/orchestrator-core 0.1.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.
- package/README.md +44 -0
- package/dist/index.d.ts +63 -0
- package/dist/index.js +175 -0
- package/dist/lib/aar-middleware.d.ts +6 -0
- package/dist/lib/aar-middleware.js +70 -0
- package/dist/lib/aar-types.d.ts +34 -0
- package/dist/lib/aar-types.js +4 -0
- package/dist/lib/acp-engine.d.ts +68 -0
- package/dist/lib/acp-engine.js +123 -0
- package/dist/lib/acp.d.ts +61 -0
- package/dist/lib/acp.js +425 -0
- package/dist/lib/agent-registry.d.ts +50 -0
- package/dist/lib/agent-registry.js +137 -0
- package/dist/lib/anthropic-direct.d.ts +27 -0
- package/dist/lib/anthropic-direct.js +109 -0
- package/dist/lib/asmr-extractor.d.ts +40 -0
- package/dist/lib/asmr-extractor.js +151 -0
- package/dist/lib/asmr-retrieval.d.ts +76 -0
- package/dist/lib/asmr-retrieval.js +311 -0
- package/dist/lib/asmr.d.ts +8 -0
- package/dist/lib/asmr.js +24 -0
- package/dist/lib/brainx-client.d.ts +72 -0
- package/dist/lib/brainx-client.js +200 -0
- package/dist/lib/brainx-embed.d.ts +14 -0
- package/dist/lib/brainx-embed.js +139 -0
- package/dist/lib/brainx-swarm-bridge.d.ts +93 -0
- package/dist/lib/brainx-swarm-bridge.js +242 -0
- package/dist/lib/byterover-client.d.ts +19 -0
- package/dist/lib/byterover-client.js +59 -0
- package/dist/lib/ceo-wallet.d.ts +37 -0
- package/dist/lib/ceo-wallet.js +176 -0
- package/dist/lib/chomsky-gate.d.ts +24 -0
- package/dist/lib/chomsky-gate.js +178 -0
- package/dist/lib/chomsky-runner.d.ts +29 -0
- package/dist/lib/chomsky-runner.js +157 -0
- package/dist/lib/citizen-score-contract.d.ts +72 -0
- package/dist/lib/citizen-score-contract.js +16 -0
- package/dist/lib/citizen-score-registry.d.ts +25 -0
- package/dist/lib/citizen-score-registry.js +65 -0
- package/dist/lib/citizenship.d.ts +103 -0
- package/dist/lib/citizenship.js +272 -0
- package/dist/lib/clawrouter-client.d.ts +37 -0
- package/dist/lib/clawrouter-client.js +148 -0
- package/dist/lib/code-asset-crystalliser.d.ts +41 -0
- package/dist/lib/code-asset-crystalliser.js +181 -0
- package/dist/lib/code-failure-logger.d.ts +27 -0
- package/dist/lib/code-failure-logger.js +42 -0
- package/dist/lib/cto-approval-gate.d.ts +45 -0
- package/dist/lib/cto-approval-gate.js +478 -0
- package/dist/lib/cto-gate-types.d.ts +28 -0
- package/dist/lib/cto-gate-types.js +8 -0
- package/dist/lib/decomposer-feedback.d.ts +54 -0
- package/dist/lib/decomposer-feedback.js +115 -0
- package/dist/lib/emotional-safety-gate.d.ts +48 -0
- package/dist/lib/emotional-safety-gate.js +97 -0
- package/dist/lib/engine-paths.d.ts +13 -0
- package/dist/lib/engine-paths.js +32 -0
- package/dist/lib/event-bus-listener.d.ts +8 -0
- package/dist/lib/event-bus-listener.js +144 -0
- package/dist/lib/event-bus-publisher.d.ts +25 -0
- package/dist/lib/event-bus-publisher.js +188 -0
- package/dist/lib/event-bus-types.d.ts +73 -0
- package/dist/lib/event-bus-types.js +23 -0
- package/dist/lib/failure-library.d.ts +178 -0
- package/dist/lib/failure-library.js +349 -0
- package/dist/lib/ksl/error-log.d.ts +28 -0
- package/dist/lib/ksl/error-log.js +43 -0
- package/dist/lib/ksl/index.d.ts +9 -0
- package/dist/lib/ksl/index.js +25 -0
- package/dist/lib/ksl/orchestrator-tap.d.ts +16 -0
- package/dist/lib/ksl/orchestrator-tap.js +85 -0
- package/dist/lib/ksl/record-writer.d.ts +46 -0
- package/dist/lib/ksl/record-writer.js +45 -0
- package/dist/lib/llm-cost-table.d.ts +36 -0
- package/dist/lib/llm-cost-table.js +90 -0
- package/dist/lib/local-model-router.d.ts +27 -0
- package/dist/lib/local-model-router.js +61 -0
- package/dist/lib/mc-client.d.ts +51 -0
- package/dist/lib/mc-client.js +249 -0
- package/dist/lib/model-router-contract.d.ts +91 -0
- package/dist/lib/model-router-contract.js +19 -0
- package/dist/lib/model-router-registry.d.ts +24 -0
- package/dist/lib/model-router-registry.js +52 -0
- package/dist/lib/model-router.d.ts +20 -0
- package/dist/lib/model-router.js +79 -0
- package/dist/lib/monotask-state-machine.d.ts +19 -0
- package/dist/lib/monotask-state-machine.js +131 -0
- package/dist/lib/neutral-prompt-checker.d.ts +22 -0
- package/dist/lib/neutral-prompt-checker.js +130 -0
- package/dist/lib/notion-direct.d.ts +92 -0
- package/dist/lib/notion-direct.js +381 -0
- package/dist/lib/ollama-client.d.ts +37 -0
- package/dist/lib/ollama-client.js +158 -0
- package/dist/lib/omel/credential-vault.d.ts +57 -0
- package/dist/lib/omel/credential-vault.js +324 -0
- package/dist/lib/omel/human-brake.d.ts +32 -0
- package/dist/lib/omel/human-brake.js +289 -0
- package/dist/lib/omel/index.d.ts +10 -0
- package/dist/lib/omel/index.js +26 -0
- package/dist/lib/omel/phantom-workspace.d.ts +31 -0
- package/dist/lib/omel/phantom-workspace.js +256 -0
- package/dist/lib/omel/wipe-witness.d.ts +75 -0
- package/dist/lib/omel/wipe-witness.js +398 -0
- package/dist/lib/orchestrate-engine.d.ts +25 -0
- package/dist/lib/orchestrate-engine.js +4436 -0
- package/dist/lib/perm-judge.d.ts +46 -0
- package/dist/lib/perm-judge.js +173 -0
- package/dist/lib/plumber/conformance.d.ts +54 -0
- package/dist/lib/plumber/conformance.js +121 -0
- package/dist/lib/plumber/index.d.ts +9 -0
- package/dist/lib/plumber/index.js +25 -0
- package/dist/lib/plumber/observer.d.ts +52 -0
- package/dist/lib/plumber/observer.js +180 -0
- package/dist/lib/plumber/types.d.ts +78 -0
- package/dist/lib/plumber/types.js +29 -0
- package/dist/lib/research-impl-gate.d.ts +16 -0
- package/dist/lib/research-impl-gate.js +105 -0
- package/dist/lib/sherlock-memory.d.ts +29 -0
- package/dist/lib/sherlock-memory.js +105 -0
- package/dist/lib/skill-crystalliser.d.ts +44 -0
- package/dist/lib/skill-crystalliser.js +60 -0
- package/dist/lib/sprint-runner-engine.d.ts +27 -0
- package/dist/lib/sprint-runner-engine.js +1042 -0
- package/dist/lib/sprint-state.d.ts +71 -0
- package/dist/lib/sprint-state.js +202 -0
- package/dist/lib/stuck-handler.d.ts +17 -0
- package/dist/lib/stuck-handler.js +249 -0
- package/dist/lib/task-contract-checker.d.ts +17 -0
- package/dist/lib/task-contract-checker.js +29 -0
- package/dist/lib/task-router/index.d.ts +17 -0
- package/dist/lib/task-router/index.js +52 -0
- package/dist/lib/task-router/router/generate-execution-id.d.ts +10 -0
- package/dist/lib/task-router/router/generate-execution-id.js +24 -0
- package/dist/lib/task-router/router/resolve-route.d.ts +2 -0
- package/dist/lib/task-router/router/resolve-route.js +49 -0
- package/dist/lib/task-router/types.d.ts +79 -0
- package/dist/lib/task-router/types.js +39 -0
- package/dist/lib/token-budget-validator.d.ts +44 -0
- package/dist/lib/token-budget-validator.js +84 -0
- package/dist/lib/trust-score-updater.d.ts +30 -0
- package/dist/lib/trust-score-updater.js +107 -0
- package/dist/lib/wallet-state.d.ts +26 -0
- package/dist/lib/wallet-state.js +85 -0
- package/package.json +27 -0
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* chomsky-gate.ts — Prompt Quality Evaluator
|
|
4
|
+
*
|
|
5
|
+
* Intercepts outbound prompts before LLM dispatch.
|
|
6
|
+
* Named after Chomsky for its linguistic quality focus.
|
|
7
|
+
*
|
|
8
|
+
* Routing: T1 LOCAL (qwen3:4b) — cost-efficient evaluation
|
|
9
|
+
* Threshold: score >= 7 PASSES, score < 7 FAILS + logs + triggers rewrite attempt
|
|
10
|
+
*/
|
|
11
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
15
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
16
|
+
}
|
|
17
|
+
Object.defineProperty(o, k2, desc);
|
|
18
|
+
}) : (function(o, m, k, k2) {
|
|
19
|
+
if (k2 === undefined) k2 = k;
|
|
20
|
+
o[k2] = m[k];
|
|
21
|
+
}));
|
|
22
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
23
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
24
|
+
}) : function(o, v) {
|
|
25
|
+
o["default"] = v;
|
|
26
|
+
});
|
|
27
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
28
|
+
var ownKeys = function(o) {
|
|
29
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
30
|
+
var ar = [];
|
|
31
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
32
|
+
return ar;
|
|
33
|
+
};
|
|
34
|
+
return ownKeys(o);
|
|
35
|
+
};
|
|
36
|
+
return function (mod) {
|
|
37
|
+
if (mod && mod.__esModule) return mod;
|
|
38
|
+
var result = {};
|
|
39
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
40
|
+
__setModuleDefault(result, mod);
|
|
41
|
+
return result;
|
|
42
|
+
};
|
|
43
|
+
})();
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.CHOMSKY_PASS_THRESHOLD = void 0;
|
|
46
|
+
exports.evaluatePromptQuality = evaluatePromptQuality;
|
|
47
|
+
const fs = __importStar(require("fs"));
|
|
48
|
+
const path = __importStar(require("path"));
|
|
49
|
+
const engine_paths_1 = require("./engine-paths");
|
|
50
|
+
const model_router_registry_1 = require("./model-router-registry");
|
|
51
|
+
// ── Config ────────────────────────────────────────────────────────────────────
|
|
52
|
+
exports.CHOMSKY_PASS_THRESHOLD = 7;
|
|
53
|
+
const EVAL_SYSTEM = `You are a prompt quality evaluator for an autonomous AI orchestration system.
|
|
54
|
+
Your job is to score outbound agent prompts before they are dispatched to LLMs.
|
|
55
|
+
Respond ONLY with valid JSON — no prose, no markdown fences, no explanation.`;
|
|
56
|
+
const EVAL_PROMPT_TEMPLATE = `Evaluate the following agent prompt on a scale of 0-10.
|
|
57
|
+
|
|
58
|
+
Scoring criteria (2 points each):
|
|
59
|
+
1. Clarity — Is the task unambiguously stated?
|
|
60
|
+
2. Specificity — Are inputs, outputs, and constraints defined?
|
|
61
|
+
3. Context — Is sufficient background provided for the agent to act correctly?
|
|
62
|
+
4. Actionability — Can the agent execute this without needing clarification?
|
|
63
|
+
5. Completeness — Are success criteria or expected outputs described?
|
|
64
|
+
|
|
65
|
+
Respond with this exact JSON structure:
|
|
66
|
+
{"score": <integer 0-10>, "issues": [<brief issue string>, ...]}
|
|
67
|
+
|
|
68
|
+
If score >= 7, issues may be an empty array [].
|
|
69
|
+
If score < 7, issues must describe what is missing or unclear.
|
|
70
|
+
|
|
71
|
+
Prompt to evaluate:
|
|
72
|
+
---
|
|
73
|
+
{{PROMPT}}
|
|
74
|
+
---`;
|
|
75
|
+
// ── Log path ──────────────────────────────────────────────────────────────────
|
|
76
|
+
function getLogPath() {
|
|
77
|
+
const today = new Date().toISOString().slice(0, 10);
|
|
78
|
+
const logDir = path.join((0, engine_paths_1.resolveEnginePaths)().root, 'logs', 'chomsky');
|
|
79
|
+
if (!fs.existsSync(logDir)) {
|
|
80
|
+
fs.mkdirSync(logDir, { recursive: true });
|
|
81
|
+
}
|
|
82
|
+
return path.join(logDir, `${today}.jsonl`);
|
|
83
|
+
}
|
|
84
|
+
function logFailure(prompt, result, agentId) {
|
|
85
|
+
const entry = {
|
|
86
|
+
timestamp: new Date().toISOString(),
|
|
87
|
+
agent_id: agentId,
|
|
88
|
+
score: result.score,
|
|
89
|
+
issues: result.issues,
|
|
90
|
+
prompt_preview: prompt.slice(0, 300),
|
|
91
|
+
passed: false,
|
|
92
|
+
};
|
|
93
|
+
try {
|
|
94
|
+
fs.appendFileSync(getLogPath(), JSON.stringify(entry) + '\n');
|
|
95
|
+
}
|
|
96
|
+
catch (_err) {
|
|
97
|
+
// Non-fatal — log write failure must not block the pipeline
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
// ── Response parser ───────────────────────────────────────────────────────────
|
|
101
|
+
function parseEvalResponse(raw) {
|
|
102
|
+
// Strip <think> blocks if present (qwen3 extended thinking)
|
|
103
|
+
const cleaned = raw.replace(/<think>[\s\S]*?<\/think>/gi, '').trim();
|
|
104
|
+
// Extract first JSON object containing score + issues
|
|
105
|
+
const jsonMatch = cleaned.match(/\{[^{}]*"score"[^{}]*"issues"[^{}]*\}/);
|
|
106
|
+
if (!jsonMatch)
|
|
107
|
+
return null;
|
|
108
|
+
try {
|
|
109
|
+
const parsed = JSON.parse(jsonMatch[0]);
|
|
110
|
+
if (typeof parsed.score === 'number' && Array.isArray(parsed.issues)) {
|
|
111
|
+
return {
|
|
112
|
+
score: Math.max(0, Math.min(10, Math.round(parsed.score))),
|
|
113
|
+
issues: parsed.issues.map(String).filter(Boolean),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
// ── Core evaluator ────────────────────────────────────────────────────────────
|
|
123
|
+
/**
|
|
124
|
+
* Evaluate the quality of an outbound agent prompt.
|
|
125
|
+
*
|
|
126
|
+
* @param prompt The prompt string about to be dispatched to an LLM agent
|
|
127
|
+
* @param agentId Identifier of the calling agent (for log attribution)
|
|
128
|
+
* @returns {score, issues, passed} — score >= 7 means gate passes
|
|
129
|
+
*/
|
|
130
|
+
async function evaluatePromptQuality(prompt, agentId = 'unknown') {
|
|
131
|
+
const evalPrompt = EVAL_PROMPT_TEMPLATE.replace('{{PROMPT}}', prompt);
|
|
132
|
+
let raw = '';
|
|
133
|
+
try {
|
|
134
|
+
const response = await (0, model_router_registry_1.getModelRouter)().routeCall({
|
|
135
|
+
task_type: 'prompt_quality_eval',
|
|
136
|
+
tier_class: 'text',
|
|
137
|
+
complexity: 'local', // T1 qwen3:4b — cost-efficient
|
|
138
|
+
context_tokens: Math.ceil((evalPrompt.length + EVAL_SYSTEM.length) / 4),
|
|
139
|
+
constitutional_flag: false,
|
|
140
|
+
agent_id: 'chomsky-gate',
|
|
141
|
+
payload: {
|
|
142
|
+
system: EVAL_SYSTEM,
|
|
143
|
+
prompt: evalPrompt,
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
raw = response.content;
|
|
147
|
+
}
|
|
148
|
+
catch (err) {
|
|
149
|
+
// LLM call failed — fail-open (pass-through) to avoid blocking the pipeline
|
|
150
|
+
return {
|
|
151
|
+
score: 7,
|
|
152
|
+
issues: [`chomsky-gate: eval skipped — LLM error: ${String(err).slice(0, 100)}`],
|
|
153
|
+
passed: true,
|
|
154
|
+
rawResponse: '',
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
const parsed = parseEvalResponse(raw);
|
|
158
|
+
if (!parsed) {
|
|
159
|
+
// Unparseable response — fail-open
|
|
160
|
+
return {
|
|
161
|
+
score: 7,
|
|
162
|
+
issues: ['chomsky-gate: eval skipped — could not parse evaluator response'],
|
|
163
|
+
passed: true,
|
|
164
|
+
rawResponse: raw,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
const passed = parsed.score >= exports.CHOMSKY_PASS_THRESHOLD;
|
|
168
|
+
const result = {
|
|
169
|
+
score: parsed.score,
|
|
170
|
+
issues: parsed.issues,
|
|
171
|
+
passed,
|
|
172
|
+
rawResponse: raw,
|
|
173
|
+
};
|
|
174
|
+
if (!passed) {
|
|
175
|
+
logFailure(prompt, result, agentId);
|
|
176
|
+
}
|
|
177
|
+
return result;
|
|
178
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* chomsky-runner.ts — Chomsky Gate Runner (CHOMSKY-02 + CHOMSKY-03)
|
|
3
|
+
*
|
|
4
|
+
* Orchestrates the full Chomsky prompt quality lifecycle:
|
|
5
|
+
* 1. Evaluate initial prompt quality via chomsky-gate
|
|
6
|
+
* 2. If score < 7: rewrite → re-evaluate (up to MAX_REWRITES = 2)
|
|
7
|
+
* 3. Log ALL evaluations (pass + fail) to logs/chomsky/YYYY-MM-DD.jsonl
|
|
8
|
+
*
|
|
9
|
+
* Routing: T1 LOCAL (qwen3:4b) — cost-efficient evaluation + rewrite
|
|
10
|
+
* Fail-open: any uncaught error returns pass-through (pipeline never blocked)
|
|
11
|
+
*/
|
|
12
|
+
export interface ChomskyRunResult {
|
|
13
|
+
finalPrompt: string;
|
|
14
|
+
initialScore: number;
|
|
15
|
+
finalScore: number;
|
|
16
|
+
rewrites: number;
|
|
17
|
+
passed: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Run the full Chomsky gate cycle for an agent prompt.
|
|
21
|
+
*
|
|
22
|
+
* Evaluates → if fail → rewrites (up to MAX_REWRITES=2) → re-evaluates each time.
|
|
23
|
+
* Logs ALL evaluations (pass and fail) to logs/chomsky/YYYY-MM-DD.jsonl.
|
|
24
|
+
* Fail-open: any uncaught error returns pass-through to avoid blocking the pipeline.
|
|
25
|
+
*
|
|
26
|
+
* @param prompt The agent context/prompt string about to be dispatched
|
|
27
|
+
* @param agentId Agent identifier for log attribution (default: 'unknown')
|
|
28
|
+
*/
|
|
29
|
+
export declare function runChomskyGate(prompt: string, agentId?: string): Promise<ChomskyRunResult>;
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* chomsky-runner.ts — Chomsky Gate Runner (CHOMSKY-02 + CHOMSKY-03)
|
|
4
|
+
*
|
|
5
|
+
* Orchestrates the full Chomsky prompt quality lifecycle:
|
|
6
|
+
* 1. Evaluate initial prompt quality via chomsky-gate
|
|
7
|
+
* 2. If score < 7: rewrite → re-evaluate (up to MAX_REWRITES = 2)
|
|
8
|
+
* 3. Log ALL evaluations (pass + fail) to logs/chomsky/YYYY-MM-DD.jsonl
|
|
9
|
+
*
|
|
10
|
+
* Routing: T1 LOCAL (qwen3:4b) — cost-efficient evaluation + rewrite
|
|
11
|
+
* Fail-open: any uncaught error returns pass-through (pipeline never blocked)
|
|
12
|
+
*/
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
30
|
+
var ownKeys = function(o) {
|
|
31
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
32
|
+
var ar = [];
|
|
33
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
34
|
+
return ar;
|
|
35
|
+
};
|
|
36
|
+
return ownKeys(o);
|
|
37
|
+
};
|
|
38
|
+
return function (mod) {
|
|
39
|
+
if (mod && mod.__esModule) return mod;
|
|
40
|
+
var result = {};
|
|
41
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
42
|
+
__setModuleDefault(result, mod);
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
})();
|
|
46
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
|
+
exports.runChomskyGate = runChomskyGate;
|
|
48
|
+
const fs = __importStar(require("fs"));
|
|
49
|
+
const path = __importStar(require("path"));
|
|
50
|
+
const engine_paths_1 = require("./engine-paths");
|
|
51
|
+
const chomsky_gate_1 = require("./chomsky-gate");
|
|
52
|
+
const model_router_registry_1 = require("./model-router-registry");
|
|
53
|
+
// ── Config ────────────────────────────────────────────────────────────────────
|
|
54
|
+
const MAX_REWRITES = 2;
|
|
55
|
+
const REWRITE_SYSTEM = 'You are a prompt engineer for an autonomous AI orchestration system. ' +
|
|
56
|
+
'Rewrite the following agent task context to be clearer, more specific, and more actionable. ' +
|
|
57
|
+
'Return only the improved context text — no prose, no preamble, no explanation.';
|
|
58
|
+
// ── JSONL logger ──────────────────────────────────────────────────────────────
|
|
59
|
+
function getLogPath() {
|
|
60
|
+
const today = new Date().toISOString().slice(0, 10);
|
|
61
|
+
const logDir = path.join((0, engine_paths_1.resolveEnginePaths)().root, 'logs', 'chomsky');
|
|
62
|
+
if (!fs.existsSync(logDir))
|
|
63
|
+
fs.mkdirSync(logDir, { recursive: true });
|
|
64
|
+
return path.join(logDir, `${today}.jsonl`);
|
|
65
|
+
}
|
|
66
|
+
function logEvalEntry(agentId, promptPreview, score, passed, issues, rewriteIndex) {
|
|
67
|
+
const entry = {
|
|
68
|
+
timestamp: new Date().toISOString(),
|
|
69
|
+
agent_id: agentId,
|
|
70
|
+
rewrite_index: rewriteIndex, // 0 = initial eval, 1+ = post-rewrite eval
|
|
71
|
+
score,
|
|
72
|
+
passed,
|
|
73
|
+
issues,
|
|
74
|
+
prompt_preview: promptPreview.slice(0, 300),
|
|
75
|
+
};
|
|
76
|
+
try {
|
|
77
|
+
fs.appendFileSync(getLogPath(), JSON.stringify(entry) + '\n');
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
// Non-fatal — log write must not block the pipeline
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// ── Rewrite helper ────────────────────────────────────────────────────────────
|
|
84
|
+
async function rewritePrompt(prompt, issues) {
|
|
85
|
+
const issueHint = issues.length > 0
|
|
86
|
+
? `\nKnown issues to address: ${issues.join('; ')}`
|
|
87
|
+
: '';
|
|
88
|
+
const response = await (0, model_router_registry_1.getModelRouter)().routeCall({
|
|
89
|
+
task_type: 'prompt_rewrite',
|
|
90
|
+
tier_class: 'text',
|
|
91
|
+
complexity: 'local',
|
|
92
|
+
context_tokens: Math.ceil((prompt.length + REWRITE_SYSTEM.length) / 4),
|
|
93
|
+
constitutional_flag: false,
|
|
94
|
+
agent_id: 'chomsky-runner',
|
|
95
|
+
payload: {
|
|
96
|
+
system: REWRITE_SYSTEM,
|
|
97
|
+
prompt: `Rewrite this agent context to score ${chomsky_gate_1.CHOMSKY_PASS_THRESHOLD}+/10 ` +
|
|
98
|
+
`on clarity, specificity, and actionability:${issueHint}\n\n${prompt}`,
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
const rewritten = response.content?.trim();
|
|
102
|
+
// Accept rewrite only if substantive
|
|
103
|
+
return rewritten && rewritten.length > 20 ? rewritten : prompt;
|
|
104
|
+
}
|
|
105
|
+
// ── Main entry point ──────────────────────────────────────────────────────────
|
|
106
|
+
/**
|
|
107
|
+
* Run the full Chomsky gate cycle for an agent prompt.
|
|
108
|
+
*
|
|
109
|
+
* Evaluates → if fail → rewrites (up to MAX_REWRITES=2) → re-evaluates each time.
|
|
110
|
+
* Logs ALL evaluations (pass and fail) to logs/chomsky/YYYY-MM-DD.jsonl.
|
|
111
|
+
* Fail-open: any uncaught error returns pass-through to avoid blocking the pipeline.
|
|
112
|
+
*
|
|
113
|
+
* @param prompt The agent context/prompt string about to be dispatched
|
|
114
|
+
* @param agentId Agent identifier for log attribution (default: 'unknown')
|
|
115
|
+
*/
|
|
116
|
+
async function runChomskyGate(prompt, agentId = 'unknown') {
|
|
117
|
+
let currentPrompt = prompt;
|
|
118
|
+
let rewrites = 0;
|
|
119
|
+
let initialScore = 7; // safe default for fail-open path
|
|
120
|
+
try {
|
|
121
|
+
// ── Cycle 0: initial evaluation ──────────────────────────────────────────
|
|
122
|
+
let evalResult = await (0, chomsky_gate_1.evaluatePromptQuality)(currentPrompt, agentId);
|
|
123
|
+
initialScore = evalResult.score;
|
|
124
|
+
logEvalEntry(agentId, currentPrompt, evalResult.score, evalResult.passed, evalResult.issues, 0);
|
|
125
|
+
// ── Rewrite loop (max MAX_REWRITES cycles) ───────────────────────────────
|
|
126
|
+
while (!evalResult.passed && rewrites < MAX_REWRITES) {
|
|
127
|
+
try {
|
|
128
|
+
currentPrompt = await rewritePrompt(currentPrompt, evalResult.issues);
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
// Rewrite is best-effort — keep current prompt, exit loop
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
rewrites++;
|
|
135
|
+
// Re-evaluate the rewritten prompt
|
|
136
|
+
evalResult = await (0, chomsky_gate_1.evaluatePromptQuality)(currentPrompt, agentId);
|
|
137
|
+
logEvalEntry(agentId, currentPrompt, evalResult.score, evalResult.passed, evalResult.issues, rewrites);
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
finalPrompt: currentPrompt,
|
|
141
|
+
initialScore,
|
|
142
|
+
finalScore: evalResult.score,
|
|
143
|
+
rewrites,
|
|
144
|
+
passed: evalResult.passed,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
// Gate is non-blocking — fail open, pass original prompt through
|
|
149
|
+
return {
|
|
150
|
+
finalPrompt: prompt,
|
|
151
|
+
initialScore,
|
|
152
|
+
finalScore: initialScore,
|
|
153
|
+
rewrites,
|
|
154
|
+
passed: true,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* citizen-score-contract.ts — TICKET-215 Wave D: the citizen-scoring SEAM.
|
|
3
|
+
*
|
|
4
|
+
* Zero-dep contract that decouples the engine from the concrete SCORE
|
|
5
|
+
* implementation. The actual scorer uses @godman-protocols/score (loaded via a
|
|
6
|
+
* vendored runtime require) — we do NOT want that in @kognai/orchestrator-core,
|
|
7
|
+
* same reasoning as viem. So core owns only the interface + types; the impl is
|
|
8
|
+
* injected (see citizen-score-registry.ts).
|
|
9
|
+
*
|
|
10
|
+
* Monitoring: scores still flow back to Kognai centrally — the registry's
|
|
11
|
+
* recordTaskScoreMonitored() emits a `data.citizen_score` event to the event-bus
|
|
12
|
+
* (Supabase kognai_events) on every record, which the Plumber observer + live
|
|
13
|
+
* dashboards consume. Seaming the COMPUTATION never silos the RESULTS.
|
|
14
|
+
*/
|
|
15
|
+
export type ACPDimension = 'safety' | 'accuracy' | 'brand_alignment' | 'cultural_sensitivity' | 'legal_compliance' | 'psychological_resilience';
|
|
16
|
+
export type SupervisorGrade = 'A' | 'B' | 'C' | 'D' | 'F';
|
|
17
|
+
export interface ScoreRubric {
|
|
18
|
+
id: string;
|
|
19
|
+
name: string;
|
|
20
|
+
version: string;
|
|
21
|
+
dimensions: Array<{
|
|
22
|
+
dimension: ACPDimension;
|
|
23
|
+
weight: number;
|
|
24
|
+
threshold: number;
|
|
25
|
+
}>;
|
|
26
|
+
}
|
|
27
|
+
export interface ScoreResult {
|
|
28
|
+
id: string;
|
|
29
|
+
rubric_id: string;
|
|
30
|
+
agent_did: string;
|
|
31
|
+
output_ref: string;
|
|
32
|
+
task_performance_score: number;
|
|
33
|
+
constitutional_multiplier: number;
|
|
34
|
+
final_score: number;
|
|
35
|
+
dimensions: Array<{
|
|
36
|
+
dimension: ACPDimension;
|
|
37
|
+
score: number;
|
|
38
|
+
passed: boolean;
|
|
39
|
+
weight: number;
|
|
40
|
+
}>;
|
|
41
|
+
harm_shield_triggered: boolean;
|
|
42
|
+
scored_at: string;
|
|
43
|
+
}
|
|
44
|
+
export interface CitizenReputation {
|
|
45
|
+
citizen_id: string;
|
|
46
|
+
agent_did: string;
|
|
47
|
+
reputation: number;
|
|
48
|
+
evaluation_count: number;
|
|
49
|
+
recent_trend: number[];
|
|
50
|
+
per_dimension: Partial<Record<ACPDimension, number>>;
|
|
51
|
+
harm_shield_history: boolean;
|
|
52
|
+
}
|
|
53
|
+
export interface TaskScoreInput {
|
|
54
|
+
citizen_id: string;
|
|
55
|
+
agent_did: string;
|
|
56
|
+
sprint_id: string;
|
|
57
|
+
task_id: string;
|
|
58
|
+
grade: SupervisorGrade;
|
|
59
|
+
supervisor_did: string;
|
|
60
|
+
harm_shield_triggered?: boolean;
|
|
61
|
+
acp_overrides?: Partial<Record<ACPDimension, number>>;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The scoring impl Kognai injects (citizen-scoring, backed by @godman-protocols/score).
|
|
65
|
+
* Products that don't score citizens simply never inject one.
|
|
66
|
+
*/
|
|
67
|
+
export interface CitizenScorer {
|
|
68
|
+
recordTaskScore(input: TaskScoreInput): ScoreResult;
|
|
69
|
+
getCitizenReputation(citizen_id: string, agent_did: string, opts?: {
|
|
70
|
+
now?: Date;
|
|
71
|
+
}): CitizenReputation;
|
|
72
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* citizen-score-contract.ts — TICKET-215 Wave D: the citizen-scoring SEAM.
|
|
4
|
+
*
|
|
5
|
+
* Zero-dep contract that decouples the engine from the concrete SCORE
|
|
6
|
+
* implementation. The actual scorer uses @godman-protocols/score (loaded via a
|
|
7
|
+
* vendored runtime require) — we do NOT want that in @kognai/orchestrator-core,
|
|
8
|
+
* same reasoning as viem. So core owns only the interface + types; the impl is
|
|
9
|
+
* injected (see citizen-score-registry.ts).
|
|
10
|
+
*
|
|
11
|
+
* Monitoring: scores still flow back to Kognai centrally — the registry's
|
|
12
|
+
* recordTaskScoreMonitored() emits a `data.citizen_score` event to the event-bus
|
|
13
|
+
* (Supabase kognai_events) on every record, which the Plumber observer + live
|
|
14
|
+
* dashboards consume. Seaming the COMPUTATION never silos the RESULTS.
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* citizen-score-registry.ts — TICKET-215 Wave D: injection point + monitoring
|
|
3
|
+
* for the citizen-scoring seam (see citizen-score-contract.ts).
|
|
4
|
+
*
|
|
5
|
+
* Kognai injects its SCORE-backed scorer at startup:
|
|
6
|
+
* setCitizenScorer(citizenScorer) // citizenScorer = the scripts/lib/citizen-scoring impl
|
|
7
|
+
*
|
|
8
|
+
* recordTaskScoreMonitored() is the engine's entry point: it scores via the
|
|
9
|
+
* injected scorer AND emits a `data.citizen_score` event to the event-bus
|
|
10
|
+
* (Supabase kognai_events) — so every score flows back to Kognai monitoring and
|
|
11
|
+
* is observable by the Plumber, regardless of where the scorer runs.
|
|
12
|
+
*
|
|
13
|
+
* The default is fail-loud: scoring with no scorer configured throws a clear,
|
|
14
|
+
* actionable error rather than silently dropping reputation data.
|
|
15
|
+
*/
|
|
16
|
+
import type { CitizenScorer, TaskScoreInput, ScoreResult } from './citizen-score-contract';
|
|
17
|
+
export declare function setCitizenScorer(scorer: CitizenScorer): void;
|
|
18
|
+
export declare function getCitizenScorer(): CitizenScorer;
|
|
19
|
+
export declare function isCitizenScorerConfigured(): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Score a task AND emit it to Kognai monitoring. The engine should call this
|
|
22
|
+
* (not the raw scorer) so every score lands in the event-bus / Plumber stream.
|
|
23
|
+
* Emission is fire-and-forget and never blocks/breaks scoring.
|
|
24
|
+
*/
|
|
25
|
+
export declare function recordTaskScoreMonitored(input: TaskScoreInput): ScoreResult;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* citizen-score-registry.ts — TICKET-215 Wave D: injection point + monitoring
|
|
4
|
+
* for the citizen-scoring seam (see citizen-score-contract.ts).
|
|
5
|
+
*
|
|
6
|
+
* Kognai injects its SCORE-backed scorer at startup:
|
|
7
|
+
* setCitizenScorer(citizenScorer) // citizenScorer = the scripts/lib/citizen-scoring impl
|
|
8
|
+
*
|
|
9
|
+
* recordTaskScoreMonitored() is the engine's entry point: it scores via the
|
|
10
|
+
* injected scorer AND emits a `data.citizen_score` event to the event-bus
|
|
11
|
+
* (Supabase kognai_events) — so every score flows back to Kognai monitoring and
|
|
12
|
+
* is observable by the Plumber, regardless of where the scorer runs.
|
|
13
|
+
*
|
|
14
|
+
* The default is fail-loud: scoring with no scorer configured throws a clear,
|
|
15
|
+
* actionable error rather than silently dropping reputation data.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.setCitizenScorer = setCitizenScorer;
|
|
19
|
+
exports.getCitizenScorer = getCitizenScorer;
|
|
20
|
+
exports.isCitizenScorerConfigured = isCitizenScorerConfigured;
|
|
21
|
+
exports.recordTaskScoreMonitored = recordTaskScoreMonitored;
|
|
22
|
+
const event_bus_publisher_1 = require("./event-bus-publisher");
|
|
23
|
+
const NOT_CONFIGURED = 'No CitizenScorer registered. Call setCitizenScorer(...) at startup ' +
|
|
24
|
+
'(Kognai injects its @godman-protocols/score-backed scorer; products that do ' +
|
|
25
|
+
'not score citizens never inject one). See @kognai/orchestrator-core citizen-score-contract.ts.';
|
|
26
|
+
class UnconfiguredCitizenScorer {
|
|
27
|
+
recordTaskScore(_input) { throw new Error(NOT_CONFIGURED); }
|
|
28
|
+
getCitizenReputation(_citizen_id, _agent_did) { throw new Error(NOT_CONFIGURED); }
|
|
29
|
+
}
|
|
30
|
+
let _scorer = new UnconfiguredCitizenScorer();
|
|
31
|
+
function setCitizenScorer(scorer) { _scorer = scorer; }
|
|
32
|
+
function getCitizenScorer() { return _scorer; }
|
|
33
|
+
function isCitizenScorerConfigured() { return !(_scorer instanceof UnconfiguredCitizenScorer); }
|
|
34
|
+
/** Build the monitoring event for a recorded score (Plumber-observable). */
|
|
35
|
+
function scoreEvent(input, result) {
|
|
36
|
+
return {
|
|
37
|
+
event_type: 'data.citizen_score',
|
|
38
|
+
agent_id: input.agent_did,
|
|
39
|
+
sprint: input.sprint_id,
|
|
40
|
+
timestamp: result.scored_at,
|
|
41
|
+
payload: {
|
|
42
|
+
citizen_id: input.citizen_id,
|
|
43
|
+
agent_did: input.agent_did,
|
|
44
|
+
task_id: input.task_id,
|
|
45
|
+
grade: input.grade,
|
|
46
|
+
final_score: result.final_score,
|
|
47
|
+
harm_shield_triggered: result.harm_shield_triggered,
|
|
48
|
+
supervisor_did: input.supervisor_did,
|
|
49
|
+
per_dimension: result.dimensions.map(d => ({ dimension: d.dimension, score: d.score, passed: d.passed })),
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Score a task AND emit it to Kognai monitoring. The engine should call this
|
|
55
|
+
* (not the raw scorer) so every score lands in the event-bus / Plumber stream.
|
|
56
|
+
* Emission is fire-and-forget and never blocks/breaks scoring.
|
|
57
|
+
*/
|
|
58
|
+
function recordTaskScoreMonitored(input) {
|
|
59
|
+
const result = getCitizenScorer().recordTaskScore(input);
|
|
60
|
+
try {
|
|
61
|
+
void (0, event_bus_publisher_1.publishEvent)(scoreEvent(input, result));
|
|
62
|
+
}
|
|
63
|
+
catch { /* monitoring must not break scoring */ }
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* citizenship.ts — Kognai citizenship issuance for spawned agents.
|
|
3
|
+
*
|
|
4
|
+
* Founder rule (2026-05-27): every agent the swarm spawns is born as a
|
|
5
|
+
* Kognai citizen — not a bare agent. Citizenship means identity (citizen
|
|
6
|
+
* ID + roll number), constitutional binding (already done via the
|
|
7
|
+
* always-on preamble), a default Kōpus avatar config, an ACP baseline
|
|
8
|
+
* score, and registration in the citizenship registry.
|
|
9
|
+
*
|
|
10
|
+
* This module:
|
|
11
|
+
* - mintCitizen(name, foundingAgent, proposingAgent): assigns ID +
|
|
12
|
+
* roll number, generates a citizen.yaml payload, appends to the
|
|
13
|
+
* registry. Atomic tmp+rename writes.
|
|
14
|
+
* - readRegistry() / writeRegistry(): registry I/O.
|
|
15
|
+
*
|
|
16
|
+
* Stdlib only. No LLM, no network. Pure issuance.
|
|
17
|
+
*/
|
|
18
|
+
export type CitizenTier = 'I' | 'II' | 'III' | 'IV';
|
|
19
|
+
export type CitizenType = 'founding' | 'spawned';
|
|
20
|
+
export interface KopusConfig {
|
|
21
|
+
/** 0–360, applied as `filter: hue-rotate(Xdeg)` to the base jade avatar. */
|
|
22
|
+
hue: number;
|
|
23
|
+
/** Default runtime state — newly minted citizens are 'idle' until first task. */
|
|
24
|
+
state: 'idle' | 'working' | 'resting' | 'training';
|
|
25
|
+
}
|
|
26
|
+
/** Sibling companies in the Kognai ecosystem. Each has its own citizen
|
|
27
|
+
* prefix and its own rollNumber sequence inside the shared registry.
|
|
28
|
+
* Add new companies here as they come online (Achiri, SCS-001, DRI, ...). */
|
|
29
|
+
export declare const COMPANY_PREFIXES: Record<string, string>;
|
|
30
|
+
export interface CitizenRecord {
|
|
31
|
+
/** Stable identifier. For company-scoped mints: `{PREFIX}-{rollNumber padded 4}`
|
|
32
|
+
* (e.g. `VXG-0042`). For legacy/Kognai-internal mints (no `company`):
|
|
33
|
+
* `Citizen-XXXXXX` (6 hex chars, kept for backward compat with the 78
|
|
34
|
+
* founding-agent backfill from 2026-05-28). */
|
|
35
|
+
citizen_id: string;
|
|
36
|
+
/** Auto-increment from the registry, scoped per-company. First spawned
|
|
37
|
+
* citizen of each company = 1. */
|
|
38
|
+
rollNumber: number;
|
|
39
|
+
/** Agent slug (matches agents/<name>/ dir within the owning company). */
|
|
40
|
+
agent_name: string;
|
|
41
|
+
/** Owning company. Defaults to 'kognai' for legacy records that predate the
|
|
42
|
+
* multi-company extension. Idempotency key is `(agent_name, company)`. */
|
|
43
|
+
company?: string;
|
|
44
|
+
/** DID for SCORE / ERC-8004 reputation tracking. Company-scoped form:
|
|
45
|
+
* `did:kognai:{company}:{agent_name}`. Legacy form (no company in path)
|
|
46
|
+
* is `did:kognai:{agent_name}`. */
|
|
47
|
+
agent_did: string;
|
|
48
|
+
/** ISO-8601 mint timestamp. */
|
|
49
|
+
mintedAt: string;
|
|
50
|
+
/** New citizens start at Tier I; promotion is constitutional. */
|
|
51
|
+
tier: CitizenTier;
|
|
52
|
+
/** Source: founding (original 29) vs spawned (CTO proposal → CEO approval). */
|
|
53
|
+
citizen_type: CitizenType;
|
|
54
|
+
/** Kōpus avatar config — randomised at mint, customisable later. */
|
|
55
|
+
mascot: KopusConfig;
|
|
56
|
+
/** ACP baseline. All citizens start at 50; earn or lose from there. */
|
|
57
|
+
reputation: number;
|
|
58
|
+
/** Lineage — who proposed and who approved. */
|
|
59
|
+
founding_agent?: string;
|
|
60
|
+
proposing_agent?: string;
|
|
61
|
+
/** Optional ticket/proposal id that produced this spawn. */
|
|
62
|
+
origin_proposal_id?: string;
|
|
63
|
+
}
|
|
64
|
+
export interface Registry {
|
|
65
|
+
total: number;
|
|
66
|
+
next_roll_number: number;
|
|
67
|
+
citizens: CitizenRecord[];
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Mint a new citizen. Assigns ID + roll number, writes the registry
|
|
71
|
+
* entry, returns the full record so callers can also persist citizen.yaml
|
|
72
|
+
* alongside the agent's other files.
|
|
73
|
+
*
|
|
74
|
+
* Idempotent by agent_name: if the agent already has a citizen record
|
|
75
|
+
* (e.g. retry / migration), returns the existing record instead of
|
|
76
|
+
* minting a duplicate.
|
|
77
|
+
*/
|
|
78
|
+
export declare function mintCitizen(agent_name: string, opts?: {
|
|
79
|
+
founding_agent?: string;
|
|
80
|
+
proposing_agent?: string;
|
|
81
|
+
origin_proposal_id?: string;
|
|
82
|
+
tier?: CitizenTier;
|
|
83
|
+
citizen_type?: CitizenType;
|
|
84
|
+
now?: Date;
|
|
85
|
+
/** Owning company. When provided, the mint uses company-scoped roll
|
|
86
|
+
* numbers (separate sequence per company), the `{PREFIX}-{rollNum padded}`
|
|
87
|
+
* citizen_id format, and the `did:kognai:{company}:{agent_name}` DID
|
|
88
|
+
* form. When omitted, behaves exactly as before (legacy Kognai-internal
|
|
89
|
+
* path: random hex citizen_id, global rollNumber sequence). */
|
|
90
|
+
company?: string;
|
|
91
|
+
}): CitizenRecord;
|
|
92
|
+
/** Lookup an existing citizen by (agent_name, company). Returns null when
|
|
93
|
+
* no match. Treats undefined company as 'kognai' for legacy compatibility. */
|
|
94
|
+
export declare function lookupCitizen(opts: {
|
|
95
|
+
agent_name: string;
|
|
96
|
+
company?: string;
|
|
97
|
+
}): CitizenRecord | null;
|
|
98
|
+
/**
|
|
99
|
+
* Render the citizen record as a citizen.yaml string for writing alongside
|
|
100
|
+
* agent.yaml in the agent's directory.
|
|
101
|
+
*/
|
|
102
|
+
export declare function renderCitizenYaml(c: CitizenRecord): string;
|
|
103
|
+
export declare function readRegistry(): Registry;
|