magi-ai 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/LICENSE +21 -0
- package/README.ja.md +377 -0
- package/README.md +377 -0
- package/dist/bin/magi-benchmark.d.ts +14 -0
- package/dist/bin/magi-benchmark.js +93 -0
- package/dist/bin/magi-mcp.d.ts +8 -0
- package/dist/bin/magi-mcp.js +28 -0
- package/dist/bin/magi.d.ts +2 -0
- package/dist/bin/magi.js +634 -0
- package/dist/src/adapters/base.d.ts +34 -0
- package/dist/src/adapters/base.js +149 -0
- package/dist/src/adapters/claude.d.ts +29 -0
- package/dist/src/adapters/claude.js +65 -0
- package/dist/src/adapters/codex.d.ts +21 -0
- package/dist/src/adapters/codex.js +41 -0
- package/dist/src/adapters/gemini.d.ts +18 -0
- package/dist/src/adapters/gemini.js +31 -0
- package/dist/src/adapters/registry.d.ts +19 -0
- package/dist/src/adapters/registry.js +59 -0
- package/dist/src/audit/hash-chain.d.ts +21 -0
- package/dist/src/audit/hash-chain.js +70 -0
- package/dist/src/audit/types.d.ts +25 -0
- package/dist/src/audit/types.js +1 -0
- package/dist/src/audit/writer.d.ts +18 -0
- package/dist/src/audit/writer.js +100 -0
- package/dist/src/benchmark/golden-tasks.d.ts +9 -0
- package/dist/src/benchmark/golden-tasks.js +476 -0
- package/dist/src/benchmark/reporter.d.ts +5 -0
- package/dist/src/benchmark/reporter.js +107 -0
- package/dist/src/benchmark/runner.d.ts +30 -0
- package/dist/src/benchmark/runner.js +224 -0
- package/dist/src/benchmark/scorer.d.ts +12 -0
- package/dist/src/benchmark/scorer.js +124 -0
- package/dist/src/benchmark/types.d.ts +54 -0
- package/dist/src/benchmark/types.js +1 -0
- package/dist/src/cache/deliberation-cache.d.ts +49 -0
- package/dist/src/cache/deliberation-cache.js +127 -0
- package/dist/src/cli/commands/config-cmd.d.ts +11 -0
- package/dist/src/cli/commands/config-cmd.js +190 -0
- package/dist/src/cli/commands/demo.d.ts +12 -0
- package/dist/src/cli/commands/demo.js +66 -0
- package/dist/src/cli/commands/setup.d.ts +7 -0
- package/dist/src/cli/commands/setup.js +182 -0
- package/dist/src/cli/i18n.d.ts +89 -0
- package/dist/src/cli/i18n.js +176 -0
- package/dist/src/cli/interactive-select.d.ts +27 -0
- package/dist/src/cli/interactive-select.js +130 -0
- package/dist/src/cli/tui-setup.d.ts +24 -0
- package/dist/src/cli/tui-setup.js +42 -0
- package/dist/src/config/cli-detector.d.ts +37 -0
- package/dist/src/config/cli-detector.js +99 -0
- package/dist/src/config/user-config.d.ts +81 -0
- package/dist/src/config/user-config.js +134 -0
- package/dist/src/context/auto-collector.d.ts +43 -0
- package/dist/src/context/auto-collector.js +337 -0
- package/dist/src/context/manager.d.ts +35 -0
- package/dist/src/context/manager.js +162 -0
- package/dist/src/context/serializer.d.ts +20 -0
- package/dist/src/context/serializer.js +52 -0
- package/dist/src/demo/recorded-deliberation.d.ts +13 -0
- package/dist/src/demo/recorded-deliberation.js +277 -0
- package/dist/src/engine/angel-detector.d.ts +83 -0
- package/dist/src/engine/angel-detector.js +334 -0
- package/dist/src/engine/at-field.d.ts +40 -0
- package/dist/src/engine/at-field.js +195 -0
- package/dist/src/engine/berserk-orchestrator.d.ts +66 -0
- package/dist/src/engine/berserk-orchestrator.js +378 -0
- package/dist/src/engine/change-metrics.d.ts +56 -0
- package/dist/src/engine/change-metrics.js +214 -0
- package/dist/src/engine/consensus.d.ts +20 -0
- package/dist/src/engine/consensus.js +146 -0
- package/dist/src/engine/dead-sea-scrolls.d.ts +132 -0
- package/dist/src/engine/dead-sea-scrolls.js +610 -0
- package/dist/src/engine/drift-detector.d.ts +39 -0
- package/dist/src/engine/drift-detector.js +225 -0
- package/dist/src/engine/dummy-plug.d.ts +44 -0
- package/dist/src/engine/dummy-plug.js +190 -0
- package/dist/src/engine/engram-manager.d.ts +55 -0
- package/dist/src/engine/engram-manager.js +306 -0
- package/dist/src/engine/events.d.ts +130 -0
- package/dist/src/engine/events.js +44 -0
- package/dist/src/engine/gospel.d.ts +30 -0
- package/dist/src/engine/gospel.js +129 -0
- package/dist/src/engine/hallucination-detector.d.ts +33 -0
- package/dist/src/engine/hallucination-detector.js +215 -0
- package/dist/src/engine/human-resolver.d.ts +19 -0
- package/dist/src/engine/human-resolver.js +89 -0
- package/dist/src/engine/instrumentality.d.ts +64 -0
- package/dist/src/engine/instrumentality.js +297 -0
- package/dist/src/engine/iruel-battle.d.ts +79 -0
- package/dist/src/engine/iruel-battle.js +319 -0
- package/dist/src/engine/kernel/deliberation-kernel.d.ts +12 -0
- package/dist/src/engine/kernel/deliberation-kernel.js +303 -0
- package/dist/src/engine/kernel/index.d.ts +8 -0
- package/dist/src/engine/kernel/index.js +7 -0
- package/dist/src/engine/kernel/phase-runner.d.ts +10 -0
- package/dist/src/engine/kernel/phase-runner.js +155 -0
- package/dist/src/engine/kernel/post-processor.d.ts +17 -0
- package/dist/src/engine/kernel/post-processor.js +131 -0
- package/dist/src/engine/kernel/types.d.ts +107 -0
- package/dist/src/engine/kernel/types.js +1 -0
- package/dist/src/engine/kernel/unit-executor.d.ts +6 -0
- package/dist/src/engine/kernel/unit-executor.js +132 -0
- package/dist/src/engine/lcl-manager.d.ts +44 -0
- package/dist/src/engine/lcl-manager.js +143 -0
- package/dist/src/engine/middleware/cache.d.ts +7 -0
- package/dist/src/engine/middleware/cache.js +29 -0
- package/dist/src/engine/middleware/chain.d.ts +18 -0
- package/dist/src/engine/middleware/chain.js +45 -0
- package/dist/src/engine/middleware/firewall.d.ts +8 -0
- package/dist/src/engine/middleware/firewall.js +24 -0
- package/dist/src/engine/middleware/index.d.ts +4 -0
- package/dist/src/engine/middleware/index.js +3 -0
- package/dist/src/engine/middleware/types.d.ts +43 -0
- package/dist/src/engine/middleware/types.js +1 -0
- package/dist/src/engine/nebuchadnezzar-key.d.ts +61 -0
- package/dist/src/engine/nebuchadnezzar-key.js +203 -0
- package/dist/src/engine/neon-genesis.d.ts +52 -0
- package/dist/src/engine/neon-genesis.js +203 -0
- package/dist/src/engine/objective-judge.d.ts +53 -0
- package/dist/src/engine/objective-judge.js +214 -0
- package/dist/src/engine/offline-mode.d.ts +18 -0
- package/dist/src/engine/offline-mode.js +46 -0
- package/dist/src/engine/orchestrator.d.ts +79 -0
- package/dist/src/engine/orchestrator.js +58 -0
- package/dist/src/engine/secret-cipher.d.ts +26 -0
- package/dist/src/engine/secret-cipher.js +114 -0
- package/dist/src/engine/seele-council.d.ts +90 -0
- package/dist/src/engine/seele-council.js +482 -0
- package/dist/src/engine/self-destruct.d.ts +61 -0
- package/dist/src/engine/self-destruct.js +231 -0
- package/dist/src/engine/self-evolution.d.ts +64 -0
- package/dist/src/engine/self-evolution.js +368 -0
- package/dist/src/engine/sync-rate.d.ts +45 -0
- package/dist/src/engine/sync-rate.js +151 -0
- package/dist/src/engine/type666-firewall.d.ts +76 -0
- package/dist/src/engine/type666-firewall.js +343 -0
- package/dist/src/engine/umbilical-cable.d.ts +41 -0
- package/dist/src/engine/umbilical-cable.js +192 -0
- package/dist/src/index.d.ts +106 -0
- package/dist/src/index.js +426 -0
- package/dist/src/mcp/server.d.ts +38 -0
- package/dist/src/mcp/server.js +196 -0
- package/dist/src/metrics/token-tracker.d.ts +38 -0
- package/dist/src/metrics/token-tracker.js +112 -0
- package/dist/src/parsers/json-extractor.d.ts +9 -0
- package/dist/src/parsers/json-extractor.js +239 -0
- package/dist/src/parsers/opinion-schema.d.ts +81 -0
- package/dist/src/parsers/opinion-schema.js +147 -0
- package/dist/src/parsers/unstructured-parser.d.ts +20 -0
- package/dist/src/parsers/unstructured-parser.js +122 -0
- package/dist/src/pipelines/architecture.d.ts +10 -0
- package/dist/src/pipelines/architecture.js +9 -0
- package/dist/src/pipelines/bug-analysis.d.ts +9 -0
- package/dist/src/pipelines/bug-analysis.js +8 -0
- package/dist/src/pipelines/code-review.d.ts +10 -0
- package/dist/src/pipelines/code-review.js +30 -0
- package/dist/src/pipelines/custom.d.ts +14 -0
- package/dist/src/pipelines/custom.js +29 -0
- package/dist/src/pipelines/registry.d.ts +9 -0
- package/dist/src/pipelines/registry.js +20 -0
- package/dist/src/prompts/personas.d.ts +6 -0
- package/dist/src/prompts/personas.js +44 -0
- package/dist/src/prompts/schemas.d.ts +4 -0
- package/dist/src/prompts/schemas.js +24 -0
- package/dist/src/prompts/templates.d.ts +6 -0
- package/dist/src/prompts/templates.js +91 -0
- package/dist/src/repl/accessibility.d.ts +23 -0
- package/dist/src/repl/accessibility.js +46 -0
- package/dist/src/repl/banner.d.ts +4 -0
- package/dist/src/repl/banner.js +28 -0
- package/dist/src/repl/boot-animation.d.ts +13 -0
- package/dist/src/repl/boot-animation.js +143 -0
- package/dist/src/repl/completer.d.ts +21 -0
- package/dist/src/repl/completer.js +168 -0
- package/dist/src/repl/context.d.ts +24 -0
- package/dist/src/repl/context.js +42 -0
- package/dist/src/repl/display-utils.d.ts +13 -0
- package/dist/src/repl/display-utils.js +65 -0
- package/dist/src/repl/event-listener.d.ts +18 -0
- package/dist/src/repl/event-listener.js +112 -0
- package/dist/src/repl/export-formatter.d.ts +8 -0
- package/dist/src/repl/export-formatter.js +73 -0
- package/dist/src/repl/ghost-text.d.ts +31 -0
- package/dist/src/repl/ghost-text.js +119 -0
- package/dist/src/repl/handoff-animation.d.ts +15 -0
- package/dist/src/repl/handoff-animation.js +65 -0
- package/dist/src/repl/history.d.ts +16 -0
- package/dist/src/repl/history.js +130 -0
- package/dist/src/repl/job-registry.d.ts +26 -0
- package/dist/src/repl/job-registry.js +80 -0
- package/dist/src/repl/magi-repl.d.ts +72 -0
- package/dist/src/repl/magi-repl.js +1008 -0
- package/dist/src/repl/multiline-input.d.ts +45 -0
- package/dist/src/repl/multiline-input.js +78 -0
- package/dist/src/repl/prompt-builder.d.ts +19 -0
- package/dist/src/repl/prompt-builder.js +36 -0
- package/dist/src/repl/repl-state.d.ts +5 -0
- package/dist/src/repl/repl-state.js +19 -0
- package/dist/src/repl/result-display.d.ts +8 -0
- package/dist/src/repl/result-display.js +195 -0
- package/dist/src/repl/session-stats.d.ts +26 -0
- package/dist/src/repl/session-stats.js +119 -0
- package/dist/src/repl/slash-commands.d.ts +60 -0
- package/dist/src/repl/slash-commands.js +725 -0
- package/dist/src/repl/terminal-sanitize.d.ts +14 -0
- package/dist/src/repl/terminal-sanitize.js +19 -0
- package/dist/src/reporters/console.d.ts +7 -0
- package/dist/src/reporters/console.js +78 -0
- package/dist/src/reporters/json.d.ts +2 -0
- package/dist/src/reporters/json.js +3 -0
- package/dist/src/reporters/markdown.d.ts +2 -0
- package/dist/src/reporters/markdown.js +65 -0
- package/dist/src/reporters/streaming.d.ts +20 -0
- package/dist/src/reporters/streaming.js +178 -0
- package/dist/src/tui/activity-log.d.ts +23 -0
- package/dist/src/tui/activity-log.js +67 -0
- package/dist/src/tui/animations.d.ts +39 -0
- package/dist/src/tui/animations.js +167 -0
- package/dist/src/tui/ansi.d.ts +28 -0
- package/dist/src/tui/ansi.js +51 -0
- package/dist/src/tui/boot-sequence.d.ts +11 -0
- package/dist/src/tui/boot-sequence.js +98 -0
- package/dist/src/tui/colors.d.ts +101 -0
- package/dist/src/tui/colors.js +71 -0
- package/dist/src/tui/header.d.ts +24 -0
- package/dist/src/tui/header.js +122 -0
- package/dist/src/tui/index.d.ts +3 -0
- package/dist/src/tui/index.js +3 -0
- package/dist/src/tui/keypress.d.ts +25 -0
- package/dist/src/tui/keypress.js +95 -0
- package/dist/src/tui/layout.d.ts +74 -0
- package/dist/src/tui/layout.js +171 -0
- package/dist/src/tui/magi-tui.d.ts +101 -0
- package/dist/src/tui/magi-tui.js +754 -0
- package/dist/src/tui/panel.d.ts +45 -0
- package/dist/src/tui/panel.js +292 -0
- package/dist/src/tui/screen-buffer.d.ts +54 -0
- package/dist/src/tui/screen-buffer.js +262 -0
- package/dist/src/tui/status-bar.d.ts +25 -0
- package/dist/src/tui/status-bar.js +124 -0
- package/dist/src/tui/terminal-detect.d.ts +26 -0
- package/dist/src/tui/terminal-detect.js +44 -0
- package/dist/src/tui/tui-helpers.d.ts +12 -0
- package/dist/src/tui/tui-helpers.js +37 -0
- package/dist/src/types/adapter.d.ts +75 -0
- package/dist/src/types/adapter.js +36 -0
- package/dist/src/types/config.d.ts +108 -0
- package/dist/src/types/config.js +85 -0
- package/dist/src/types/consensus.d.ts +55 -0
- package/dist/src/types/consensus.js +17 -0
- package/dist/src/types/core.d.ts +178 -0
- package/dist/src/types/core.js +85 -0
- package/dist/src/types/magi-api.d.ts +62 -0
- package/dist/src/types/magi-api.js +7 -0
- package/dist/src/types/phase-h.d.ts +142 -0
- package/dist/src/types/phase-h.js +7 -0
- package/dist/src/types/phase-i.d.ts +186 -0
- package/dist/src/types/phase-i.js +6 -0
- package/dist/src/types/phase-k.d.ts +259 -0
- package/dist/src/types/phase-k.js +6 -0
- package/dist/src/types/phase-l.d.ts +199 -0
- package/dist/src/types/phase-l.js +6 -0
- package/dist/src/types/pipeline.d.ts +37 -0
- package/dist/src/types/pipeline.js +2 -0
- package/dist/src/utils/abstain-factory.d.ts +2 -0
- package/dist/src/utils/abstain-factory.js +18 -0
- package/dist/src/utils/errors.d.ts +34 -0
- package/dist/src/utils/errors.js +59 -0
- package/dist/src/utils/file-validator.d.ts +50 -0
- package/dist/src/utils/file-validator.js +124 -0
- package/dist/src/utils/fire-and-forget.d.ts +5 -0
- package/dist/src/utils/fire-and-forget.js +10 -0
- package/dist/src/utils/flag-validator.d.ts +21 -0
- package/dist/src/utils/flag-validator.js +79 -0
- package/dist/src/utils/freeze.d.ts +8 -0
- package/dist/src/utils/freeze.js +16 -0
- package/dist/src/utils/language-detector.d.ts +16 -0
- package/dist/src/utils/language-detector.js +159 -0
- package/dist/src/utils/latency-tracker.d.ts +45 -0
- package/dist/src/utils/latency-tracker.js +100 -0
- package/dist/src/utils/logger.d.ts +33 -0
- package/dist/src/utils/logger.js +112 -0
- package/dist/src/utils/process.d.ts +40 -0
- package/dist/src/utils/process.js +253 -0
- package/dist/src/utils/retry.d.ts +12 -0
- package/dist/src/utils/retry.js +30 -0
- package/dist/src/utils/safe-fs.d.ts +38 -0
- package/dist/src/utils/safe-fs.js +56 -0
- package/dist/src/utils/safe-json-parse.d.ts +15 -0
- package/dist/src/utils/safe-json-parse.js +49 -0
- package/dist/src/utils/sanitize.d.ts +14 -0
- package/dist/src/utils/sanitize.js +186 -0
- package/dist/src/utils/semaphore.d.ts +22 -0
- package/dist/src/utils/semaphore.js +57 -0
- package/dist/src/utils/shutdown.d.ts +6 -0
- package/dist/src/utils/shutdown.js +51 -0
- package/dist/src/utils/tty.d.ts +5 -0
- package/dist/src/utils/tty.js +7 -0
- package/package.json +82 -0
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
/** MAGI unit identifier — string to support N-body configurations (2-7 units) */
|
|
3
|
+
export type MagiUnit = string;
|
|
4
|
+
/** Built-in MAGI unit identifiers for the classic 3-body configuration */
|
|
5
|
+
export type BuiltinMagiUnit = 'MELCHIOR' | 'BALTHASAR' | 'CASPER';
|
|
6
|
+
/** Definition of a MAGI unit */
|
|
7
|
+
export interface MagiUnitDefinition {
|
|
8
|
+
id: string;
|
|
9
|
+
displayName: string;
|
|
10
|
+
role: string;
|
|
11
|
+
focus: string;
|
|
12
|
+
weight: number;
|
|
13
|
+
}
|
|
14
|
+
/** Built-in MAGI unit definitions */
|
|
15
|
+
export declare const BUILTIN_UNITS: Record<BuiltinMagiUnit, MagiUnitDefinition>;
|
|
16
|
+
/** Underlying CLI tool identifier */
|
|
17
|
+
export type CliTool = 'claude' | 'codex' | 'gemini';
|
|
18
|
+
/** Mapping from MAGI unit to CLI tool (built-in units only) */
|
|
19
|
+
export declare const MAGI_CLI_MAP: {
|
|
20
|
+
readonly MELCHIOR: "claude";
|
|
21
|
+
readonly BALTHASAR: "codex";
|
|
22
|
+
readonly CASPER: "gemini";
|
|
23
|
+
};
|
|
24
|
+
/** Reverse mapping from CLI tool to MAGI unit (built-in units only) */
|
|
25
|
+
export declare const CLI_MAGI_MAP: {
|
|
26
|
+
readonly claude: "MELCHIOR";
|
|
27
|
+
readonly codex: "BALTHASAR";
|
|
28
|
+
readonly gemini: "CASPER";
|
|
29
|
+
};
|
|
30
|
+
/** MAGI persona descriptions (backward compat, derived from BUILTIN_UNITS) */
|
|
31
|
+
export declare const MAGI_PERSONAS: {
|
|
32
|
+
readonly MELCHIOR: {
|
|
33
|
+
readonly name: string;
|
|
34
|
+
readonly role: string;
|
|
35
|
+
readonly focus: string;
|
|
36
|
+
};
|
|
37
|
+
readonly BALTHASAR: {
|
|
38
|
+
readonly name: string;
|
|
39
|
+
readonly role: string;
|
|
40
|
+
readonly focus: string;
|
|
41
|
+
};
|
|
42
|
+
readonly CASPER: {
|
|
43
|
+
readonly name: string;
|
|
44
|
+
readonly role: string;
|
|
45
|
+
readonly focus: string;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
/** Vote schema: normalizes case and whitespace → enum literal */
|
|
49
|
+
export declare const VoteSchema: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodEnum<{
|
|
50
|
+
APPROVE: "APPROVE";
|
|
51
|
+
REJECT: "REJECT";
|
|
52
|
+
ABSTAIN: "ABSTAIN";
|
|
53
|
+
}>>;
|
|
54
|
+
/** Confidence schema: clamps to 0.0-1.0 range */
|
|
55
|
+
export declare const ConfidenceSchema: z.ZodPipe<z.ZodNumber, z.ZodTransform<number, number>>;
|
|
56
|
+
/** UUID v4 format regex */
|
|
57
|
+
export declare const UUID_V4_RE: RegExp;
|
|
58
|
+
/** Zod schema for task ID validation (UUID v4 format) */
|
|
59
|
+
export declare const MagiTaskIdSchema: z.ZodString;
|
|
60
|
+
/** Zod schema for task type validation */
|
|
61
|
+
export declare const TaskTypeSchema: z.ZodEnum<{
|
|
62
|
+
custom: "custom";
|
|
63
|
+
"code-review": "code-review";
|
|
64
|
+
"architecture-decision": "architecture-decision";
|
|
65
|
+
"bug-analysis": "bug-analysis";
|
|
66
|
+
"implementation-plan": "implementation-plan";
|
|
67
|
+
"security-audit": "security-audit";
|
|
68
|
+
}>;
|
|
69
|
+
/** Zod schema for task artifact validation */
|
|
70
|
+
export declare const TaskArtifactSchema: z.ZodObject<{
|
|
71
|
+
type: z.ZodEnum<{
|
|
72
|
+
file: "file";
|
|
73
|
+
diff: "diff";
|
|
74
|
+
snippet: "snippet";
|
|
75
|
+
url: "url";
|
|
76
|
+
}>;
|
|
77
|
+
path: z.ZodOptional<z.ZodString>;
|
|
78
|
+
content: z.ZodOptional<z.ZodString>;
|
|
79
|
+
language: z.ZodOptional<z.ZodString>;
|
|
80
|
+
label: z.ZodOptional<z.ZodString>;
|
|
81
|
+
}, z.core.$strip>;
|
|
82
|
+
/** Zod schema for MagiTask validation */
|
|
83
|
+
export declare const MagiTaskSchema: z.ZodObject<{
|
|
84
|
+
id: z.ZodOptional<z.ZodString>;
|
|
85
|
+
type: z.ZodEnum<{
|
|
86
|
+
custom: "custom";
|
|
87
|
+
"code-review": "code-review";
|
|
88
|
+
"architecture-decision": "architecture-decision";
|
|
89
|
+
"bug-analysis": "bug-analysis";
|
|
90
|
+
"implementation-plan": "implementation-plan";
|
|
91
|
+
"security-audit": "security-audit";
|
|
92
|
+
}>;
|
|
93
|
+
title: z.ZodString;
|
|
94
|
+
description: z.ZodString;
|
|
95
|
+
artifacts: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
96
|
+
type: z.ZodEnum<{
|
|
97
|
+
file: "file";
|
|
98
|
+
diff: "diff";
|
|
99
|
+
snippet: "snippet";
|
|
100
|
+
url: "url";
|
|
101
|
+
}>;
|
|
102
|
+
path: z.ZodOptional<z.ZodString>;
|
|
103
|
+
content: z.ZodOptional<z.ZodString>;
|
|
104
|
+
language: z.ZodOptional<z.ZodString>;
|
|
105
|
+
label: z.ZodOptional<z.ZodString>;
|
|
106
|
+
}, z.core.$strip>>>;
|
|
107
|
+
context: z.ZodOptional<z.ZodString>;
|
|
108
|
+
}, z.core.$strip>;
|
|
109
|
+
/** Vote choices in MAGI deliberation (derived from VoteSchema) */
|
|
110
|
+
export type Vote = z.infer<typeof VoteSchema>;
|
|
111
|
+
/** Confidence level for a vote (0.0 - 1.0) (derived from ConfidenceSchema) */
|
|
112
|
+
export type Confidence = z.infer<typeof ConfidenceSchema>;
|
|
113
|
+
/** Supported task types (derived from TaskTypeSchema) */
|
|
114
|
+
export type TaskType = z.infer<typeof TaskTypeSchema>;
|
|
115
|
+
/** File or code artifact attached to a task (derived from TaskArtifactSchema) */
|
|
116
|
+
export type TaskArtifact = z.infer<typeof TaskArtifactSchema>;
|
|
117
|
+
/**
|
|
118
|
+
* Task submitted for MAGI deliberation.
|
|
119
|
+
*
|
|
120
|
+
* Core fields are derived from MagiTaskSchema. The `config` field is
|
|
121
|
+
* an extension not covered by the schema (pipeline-specific override).
|
|
122
|
+
*/
|
|
123
|
+
export type MagiTask = z.infer<typeof MagiTaskSchema> & {
|
|
124
|
+
config?: import('./pipeline.js').PipelineConfigOverride;
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* A single MAGI unit's opinion on a matter.
|
|
128
|
+
*
|
|
129
|
+
* The payload fields (vote, confidence, reasoning, keyPoints, suggestions)
|
|
130
|
+
* overlap with OpinionPayloadSchema in parsers/opinion-schema.ts.
|
|
131
|
+
* The extra fields (unit, rawOutput, meta) are adapter-level concerns
|
|
132
|
+
* not part of the validated payload, so MagiOpinion remains a manual
|
|
133
|
+
* interface to avoid circular imports.
|
|
134
|
+
*/
|
|
135
|
+
export interface MagiOpinion {
|
|
136
|
+
unit: MagiUnit;
|
|
137
|
+
vote: Vote;
|
|
138
|
+
confidence: Confidence;
|
|
139
|
+
reasoning: string;
|
|
140
|
+
keyPoints: string[];
|
|
141
|
+
suggestions?: string[];
|
|
142
|
+
rawOutput: string;
|
|
143
|
+
meta: ExecutionMeta;
|
|
144
|
+
}
|
|
145
|
+
/** Metadata about CLI execution */
|
|
146
|
+
export interface ExecutionMeta {
|
|
147
|
+
durationMs: number;
|
|
148
|
+
exitCode: number;
|
|
149
|
+
model?: string;
|
|
150
|
+
tokens?: {
|
|
151
|
+
input?: number;
|
|
152
|
+
output?: number;
|
|
153
|
+
};
|
|
154
|
+
retryCount: number;
|
|
155
|
+
structuredOutput: boolean;
|
|
156
|
+
}
|
|
157
|
+
/** A complete deliberation round */
|
|
158
|
+
export interface DeliberationRound {
|
|
159
|
+
roundNumber: number;
|
|
160
|
+
phase: DeliberationPhase;
|
|
161
|
+
opinions: MagiOpinion[];
|
|
162
|
+
startedAt: Date;
|
|
163
|
+
completedAt: Date;
|
|
164
|
+
}
|
|
165
|
+
/** Phases of deliberation */
|
|
166
|
+
export type DeliberationPhase = 'initial-opinion' | 'cross-examination' | 'final-vote';
|
|
167
|
+
/** The complete result of a MAGI deliberation */
|
|
168
|
+
export interface MagiDeliberation {
|
|
169
|
+
id: string;
|
|
170
|
+
task: MagiTask;
|
|
171
|
+
rounds: DeliberationRound[];
|
|
172
|
+
consensus: import('./consensus.js').ConsensusResult;
|
|
173
|
+
totalDurationMs: number;
|
|
174
|
+
startedAt: Date;
|
|
175
|
+
completedAt: Date;
|
|
176
|
+
fromCache?: boolean;
|
|
177
|
+
objectiveResult?: import('../engine/objective-judge.js').ObjectiveResult;
|
|
178
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
/** Built-in MAGI unit definitions */
|
|
3
|
+
export const BUILTIN_UNITS = {
|
|
4
|
+
MELCHIOR: {
|
|
5
|
+
id: 'MELCHIOR',
|
|
6
|
+
displayName: 'MELCHIOR-1',
|
|
7
|
+
role: 'Scientist (科学者)',
|
|
8
|
+
focus: 'Rigorous logic, correctness, type safety, edge cases, algorithmic efficiency',
|
|
9
|
+
weight: 1.0,
|
|
10
|
+
},
|
|
11
|
+
BALTHASAR: {
|
|
12
|
+
id: 'BALTHASAR',
|
|
13
|
+
displayName: 'BALTHASAR-2',
|
|
14
|
+
role: 'Pragmatist (実装者)',
|
|
15
|
+
focus: 'Practical implementation, readability, maintainability, real-world usage patterns',
|
|
16
|
+
weight: 1.0,
|
|
17
|
+
},
|
|
18
|
+
CASPER: {
|
|
19
|
+
id: 'CASPER',
|
|
20
|
+
displayName: 'CASPER-3',
|
|
21
|
+
role: 'Reviewer (審査者)',
|
|
22
|
+
focus: 'Safety, security, risk assessment, architectural implications, big picture',
|
|
23
|
+
weight: 1.0,
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
/** Mapping from MAGI unit to CLI tool (built-in units only) */
|
|
27
|
+
export const MAGI_CLI_MAP = {
|
|
28
|
+
MELCHIOR: 'claude',
|
|
29
|
+
BALTHASAR: 'codex',
|
|
30
|
+
CASPER: 'gemini',
|
|
31
|
+
};
|
|
32
|
+
/** Reverse mapping from CLI tool to MAGI unit (built-in units only) */
|
|
33
|
+
export const CLI_MAGI_MAP = {
|
|
34
|
+
claude: 'MELCHIOR',
|
|
35
|
+
codex: 'BALTHASAR',
|
|
36
|
+
gemini: 'CASPER',
|
|
37
|
+
};
|
|
38
|
+
/** MAGI persona descriptions (backward compat, derived from BUILTIN_UNITS) */
|
|
39
|
+
export const MAGI_PERSONAS = {
|
|
40
|
+
MELCHIOR: { name: BUILTIN_UNITS.MELCHIOR.displayName, role: BUILTIN_UNITS.MELCHIOR.role, focus: BUILTIN_UNITS.MELCHIOR.focus },
|
|
41
|
+
BALTHASAR: { name: BUILTIN_UNITS.BALTHASAR.displayName, role: BUILTIN_UNITS.BALTHASAR.role, focus: BUILTIN_UNITS.BALTHASAR.focus },
|
|
42
|
+
CASPER: { name: BUILTIN_UNITS.CASPER.displayName, role: BUILTIN_UNITS.CASPER.role, focus: BUILTIN_UNITS.CASPER.focus },
|
|
43
|
+
};
|
|
44
|
+
// ============================================================
|
|
45
|
+
// Zod Schemas (Single Source of Truth for runtime validation + type derivation)
|
|
46
|
+
// ============================================================
|
|
47
|
+
/** Vote schema: normalizes case and whitespace → enum literal */
|
|
48
|
+
export const VoteSchema = z
|
|
49
|
+
.string()
|
|
50
|
+
.transform((v) => v.trim().toUpperCase())
|
|
51
|
+
.pipe(z.enum(['APPROVE', 'REJECT', 'ABSTAIN']));
|
|
52
|
+
/** Confidence schema: clamps to 0.0-1.0 range */
|
|
53
|
+
export const ConfidenceSchema = z
|
|
54
|
+
.number()
|
|
55
|
+
.transform((n) => Math.max(0, Math.min(1, n)));
|
|
56
|
+
/** UUID v4 format regex */
|
|
57
|
+
export const UUID_V4_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
58
|
+
/** Zod schema for task ID validation (UUID v4 format) */
|
|
59
|
+
export const MagiTaskIdSchema = z.string().regex(UUID_V4_RE, 'Task ID must be a valid UUID v4');
|
|
60
|
+
/** Zod schema for task type validation */
|
|
61
|
+
export const TaskTypeSchema = z.enum([
|
|
62
|
+
'code-review',
|
|
63
|
+
'architecture-decision',
|
|
64
|
+
'bug-analysis',
|
|
65
|
+
'implementation-plan',
|
|
66
|
+
'security-audit',
|
|
67
|
+
'custom',
|
|
68
|
+
]);
|
|
69
|
+
/** Zod schema for task artifact validation */
|
|
70
|
+
export const TaskArtifactSchema = z.object({
|
|
71
|
+
type: z.enum(['file', 'diff', 'snippet', 'url']),
|
|
72
|
+
path: z.string().optional(),
|
|
73
|
+
content: z.string().optional(),
|
|
74
|
+
language: z.string().optional(),
|
|
75
|
+
label: z.string().optional(),
|
|
76
|
+
});
|
|
77
|
+
/** Zod schema for MagiTask validation */
|
|
78
|
+
export const MagiTaskSchema = z.object({
|
|
79
|
+
id: MagiTaskIdSchema.optional(),
|
|
80
|
+
type: TaskTypeSchema,
|
|
81
|
+
title: z.string().min(1).max(500),
|
|
82
|
+
description: z.string().min(1).max(50_000),
|
|
83
|
+
artifacts: z.array(TaskArtifactSchema).optional(),
|
|
84
|
+
context: z.string().max(200_000).optional(),
|
|
85
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MAGI Namespaced API type definitions.
|
|
3
|
+
*
|
|
4
|
+
* Three namespaces: runtime / diagnostics / admin
|
|
5
|
+
* All exposed via readonly getters on the Magi class.
|
|
6
|
+
*/
|
|
7
|
+
import type { AngelDetection, CochangeEdge, Prophecy, ProphecyAccuracy, FirewallResult, NebuchadnezzarState, SelfDestructMotion, SelfDestructPhase } from './phase-k.js';
|
|
8
|
+
import type { IruelBattlePhase, EvolutionGeneration, DiagnosticStats, SeeleSession, GenesisLog, MagiNodeId } from './phase-l.js';
|
|
9
|
+
import type { MagiUnit, Vote } from './core.js';
|
|
10
|
+
export interface WatchHandle {
|
|
11
|
+
stop(): void;
|
|
12
|
+
readonly running: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface MagiRuntime {
|
|
15
|
+
startWatch(opts?: {
|
|
16
|
+
pollIntervalMs?: number;
|
|
17
|
+
signal?: AbortSignal;
|
|
18
|
+
}): WatchHandle;
|
|
19
|
+
stopWatch(): void;
|
|
20
|
+
detectFromCommit(hash: string): Promise<AngelDetection[]>;
|
|
21
|
+
getCochangeGraph(): CochangeEdge[];
|
|
22
|
+
analyzeFile(filePath: string): Promise<Prophecy>;
|
|
23
|
+
analyzeAll(dirPath: string): Promise<Prophecy[]>;
|
|
24
|
+
getScrollsAccuracy(): ProphecyAccuracy;
|
|
25
|
+
scanFirewall(input: string): FirewallResult;
|
|
26
|
+
getFirewallStats(): {
|
|
27
|
+
patternCount: number;
|
|
28
|
+
dynamicCount: number;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export interface MagiDiagnostics {
|
|
32
|
+
simulateIruelBattle(): Promise<IruelBattlePhase>;
|
|
33
|
+
getIruelPhase(): IruelBattlePhase;
|
|
34
|
+
resetIruelBattle(): void;
|
|
35
|
+
computeASI(unit: string): number;
|
|
36
|
+
checkDrift(unit: string): boolean;
|
|
37
|
+
evolve(opts?: {
|
|
38
|
+
dryRun?: boolean;
|
|
39
|
+
maxProposals?: number;
|
|
40
|
+
}): Promise<EvolutionGeneration>;
|
|
41
|
+
diagnose(): Promise<DiagnosticStats>;
|
|
42
|
+
getChronicleEntryCount(): number;
|
|
43
|
+
getLCLDensity(phase: string): number;
|
|
44
|
+
}
|
|
45
|
+
export interface MagiAdmin {
|
|
46
|
+
simulateSeele(opts?: {
|
|
47
|
+
attack?: boolean;
|
|
48
|
+
}): Promise<SeeleSession>;
|
|
49
|
+
executeSeeleAttack(attackers: MagiNodeId[], target: MagiNodeId): Promise<{
|
|
50
|
+
success: boolean;
|
|
51
|
+
defenseHeld: boolean;
|
|
52
|
+
}>;
|
|
53
|
+
formatSeelePanel(): string;
|
|
54
|
+
fileDestructMotion(reason: string): SelfDestructMotion;
|
|
55
|
+
castDestructVote(motionId: string, unit: MagiUnit, vote: Vote): void;
|
|
56
|
+
executeDestruct(motionId: string): Promise<SelfDestructMotion>;
|
|
57
|
+
getDestructPhase(): SelfDestructPhase;
|
|
58
|
+
resetDestruct(): void;
|
|
59
|
+
executeGenesis(reason: string, force?: boolean): Promise<GenesisLog>;
|
|
60
|
+
loadGenesisLog(): Promise<GenesisLog | null>;
|
|
61
|
+
getNebuchadnezzarState(): NebuchadnezzarState | null;
|
|
62
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase H (Soul Plan) — Type definitions
|
|
3
|
+
*
|
|
4
|
+
* エヴァンゲリオンの世界観をMAGIシステムに技術的に組み込むための
|
|
5
|
+
* 全モジュール共通型定義。
|
|
6
|
+
*/
|
|
7
|
+
import type { MagiUnit, MagiOpinion, Vote } from './core.js';
|
|
8
|
+
import type { ConsensusDecision } from './consensus.js';
|
|
9
|
+
/** Beta distribution parameters for Bayesian sync rate estimation */
|
|
10
|
+
export interface BetaParams {
|
|
11
|
+
alpha: number;
|
|
12
|
+
beta: number;
|
|
13
|
+
}
|
|
14
|
+
/** A single sync rate entry for a (unit, domain) pair */
|
|
15
|
+
export interface SyncRateEntry {
|
|
16
|
+
params: BetaParams;
|
|
17
|
+
updatedAt: string;
|
|
18
|
+
}
|
|
19
|
+
/** Map of domain → sync rate entry */
|
|
20
|
+
export type UnitSyncRates = Record<string, SyncRateEntry>;
|
|
21
|
+
/** Map of unit → weight for consensus injection */
|
|
22
|
+
export type SyncWeightMap = Partial<Record<MagiUnit, number>>;
|
|
23
|
+
/** A.T. Field threat level */
|
|
24
|
+
export type ATFieldLevel = 1 | 2 | 3 | 'MAX';
|
|
25
|
+
/** Result of bias detection analysis */
|
|
26
|
+
export interface BiasDetectionResult {
|
|
27
|
+
level: ATFieldLevel;
|
|
28
|
+
voteEntropy: number;
|
|
29
|
+
confidenceVariance: number;
|
|
30
|
+
jaccardDistance: number;
|
|
31
|
+
unanimousStreak: number;
|
|
32
|
+
biasWarning: boolean;
|
|
33
|
+
confidenceDiscount: number;
|
|
34
|
+
catfishAdvocate?: string;
|
|
35
|
+
deliberationId: string;
|
|
36
|
+
}
|
|
37
|
+
/** Types of milestones the chronicle can detect */
|
|
38
|
+
export type MilestoneType = 'first_deliberation' | 'first_unanimous' | 'first_deadlock' | 'centenary' | 'millennium';
|
|
39
|
+
/** A single entry in the chronicle */
|
|
40
|
+
export interface ChronicleEntry {
|
|
41
|
+
number: number;
|
|
42
|
+
deliberationId: string;
|
|
43
|
+
taskType: string;
|
|
44
|
+
taskTitle: string;
|
|
45
|
+
decision: ConsensusDecision;
|
|
46
|
+
confidence: number;
|
|
47
|
+
units: string[];
|
|
48
|
+
milestone?: MilestoneType;
|
|
49
|
+
timestamp: string;
|
|
50
|
+
}
|
|
51
|
+
/** Encrypted cipher block stored on disk */
|
|
52
|
+
export interface CipherBlock {
|
|
53
|
+
iv: string;
|
|
54
|
+
authTag: string;
|
|
55
|
+
encrypted: string;
|
|
56
|
+
salt?: string;
|
|
57
|
+
createdAt: string;
|
|
58
|
+
}
|
|
59
|
+
/** Cable connection status */
|
|
60
|
+
export type CableStatus = 'connected' | 'degraded' | 'disconnected';
|
|
61
|
+
/** State of a single unit's umbilical cable */
|
|
62
|
+
export interface UmbilicalState {
|
|
63
|
+
unit: MagiUnit;
|
|
64
|
+
status: CableStatus;
|
|
65
|
+
recentResults: ('SUCCESS' | 'TIMEOUT' | 'CRASH')[];
|
|
66
|
+
disconnectedAt?: number;
|
|
67
|
+
batteryLimitMs: number;
|
|
68
|
+
}
|
|
69
|
+
/** A dummy plug generated opinion (extends MagiOpinion conceptually) */
|
|
70
|
+
export interface DummyPlugOpinion extends MagiOpinion {
|
|
71
|
+
isDummyPlug: true;
|
|
72
|
+
sourceUnit: MagiUnit;
|
|
73
|
+
profileSamples: number;
|
|
74
|
+
}
|
|
75
|
+
/** Result of a recovery protocol brief */
|
|
76
|
+
export interface RecoveryProtocolResult {
|
|
77
|
+
unit: MagiUnit;
|
|
78
|
+
missedRounds: number;
|
|
79
|
+
brief: string;
|
|
80
|
+
generatedAt: string;
|
|
81
|
+
}
|
|
82
|
+
/** Behavior profile for a unit (used by DummyPlug) */
|
|
83
|
+
export interface UnitProfile {
|
|
84
|
+
voteDistribution: Record<Vote, number>;
|
|
85
|
+
averageConfidence: number;
|
|
86
|
+
frequentKeyPoints: string[];
|
|
87
|
+
domainProfiles: Record<string, {
|
|
88
|
+
voteDistribution: Record<Vote, number>;
|
|
89
|
+
averageConfidence: number;
|
|
90
|
+
}>;
|
|
91
|
+
sampleCount: number;
|
|
92
|
+
}
|
|
93
|
+
export interface SyncRateUpdatedEvent {
|
|
94
|
+
deliberationId: string;
|
|
95
|
+
rates: Record<MagiUnit, number>;
|
|
96
|
+
domain: string;
|
|
97
|
+
emittedAt: Date;
|
|
98
|
+
}
|
|
99
|
+
export interface BerserkWarningEvent {
|
|
100
|
+
deliberationId: string;
|
|
101
|
+
totalSyncRate: number;
|
|
102
|
+
threshold: number;
|
|
103
|
+
units: Record<MagiUnit, number>;
|
|
104
|
+
emittedAt: Date;
|
|
105
|
+
}
|
|
106
|
+
export interface BiasDetectedEvent {
|
|
107
|
+
deliberationId: string;
|
|
108
|
+
level: ATFieldLevel;
|
|
109
|
+
biasWarning: boolean;
|
|
110
|
+
confidenceDiscount: number;
|
|
111
|
+
voteEntropy: number;
|
|
112
|
+
emittedAt: Date;
|
|
113
|
+
}
|
|
114
|
+
export interface GospelMilestoneEvent {
|
|
115
|
+
deliberationId: string;
|
|
116
|
+
milestone: MilestoneType;
|
|
117
|
+
count: number;
|
|
118
|
+
emittedAt: Date;
|
|
119
|
+
}
|
|
120
|
+
export interface UmbilicalStatusChangedEvent {
|
|
121
|
+
unit: MagiUnit;
|
|
122
|
+
previousStatus: CableStatus;
|
|
123
|
+
newStatus: CableStatus;
|
|
124
|
+
emittedAt: Date;
|
|
125
|
+
}
|
|
126
|
+
export interface DummyPlugActivatedEvent {
|
|
127
|
+
deliberationId: string;
|
|
128
|
+
unit: MagiUnit;
|
|
129
|
+
confidence: number;
|
|
130
|
+
profileSamples: number;
|
|
131
|
+
emittedAt: Date;
|
|
132
|
+
}
|
|
133
|
+
export interface DummyPlugRecoveryEvent {
|
|
134
|
+
unit: MagiUnit;
|
|
135
|
+
missedRounds: number;
|
|
136
|
+
emittedAt: Date;
|
|
137
|
+
}
|
|
138
|
+
export interface CipherDiscoveredEvent {
|
|
139
|
+
deliberationId: string;
|
|
140
|
+
deliberationCount: number;
|
|
141
|
+
emittedAt: Date;
|
|
142
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase I (ロマン基盤構築層) — Type definitions
|
|
3
|
+
*
|
|
4
|
+
* A-01 記憶・人格 / A-03 暴走モード / A-05 補完計画 / B-02 LCL
|
|
5
|
+
*/
|
|
6
|
+
import type { MagiUnit, MagiOpinion } from './core.js';
|
|
7
|
+
import type { ConsensusDecision } from './consensus.js';
|
|
8
|
+
/** A single episodic memory of a past deliberation */
|
|
9
|
+
export interface EpisodicMemory {
|
|
10
|
+
deliberationId: string;
|
|
11
|
+
taskType: string;
|
|
12
|
+
taskTitle: string;
|
|
13
|
+
taskDescription: string;
|
|
14
|
+
decision: ConsensusDecision;
|
|
15
|
+
confidence: number;
|
|
16
|
+
keyPoints: string[];
|
|
17
|
+
units: MagiUnit[];
|
|
18
|
+
timestamp: string;
|
|
19
|
+
}
|
|
20
|
+
/** Compressed semantic pattern extracted from episodic memories */
|
|
21
|
+
export interface SemanticPattern {
|
|
22
|
+
pattern: string;
|
|
23
|
+
frequency: number;
|
|
24
|
+
domains: string[];
|
|
25
|
+
confidence: number;
|
|
26
|
+
extractedAt: string;
|
|
27
|
+
}
|
|
28
|
+
/** Procedural strategy derived from successful deliberation patterns */
|
|
29
|
+
export interface ProceduralStrategy {
|
|
30
|
+
taskType: string;
|
|
31
|
+
strategy: string;
|
|
32
|
+
successRate: number;
|
|
33
|
+
sampleCount: number;
|
|
34
|
+
lastUsed: string;
|
|
35
|
+
}
|
|
36
|
+
/** 12-dimensional behavior vector for drift detection */
|
|
37
|
+
export interface BehaviorVector {
|
|
38
|
+
approveRate: number;
|
|
39
|
+
rejectRate: number;
|
|
40
|
+
abstainRate: number;
|
|
41
|
+
avgConfidence: number;
|
|
42
|
+
avgKeyPointCount: number;
|
|
43
|
+
avgReasoningLength: number;
|
|
44
|
+
agreementRate: number;
|
|
45
|
+
dissenterRate: number;
|
|
46
|
+
responseTimeNorm: number;
|
|
47
|
+
vocabularyDiversity: number;
|
|
48
|
+
sentimentPolarity: number;
|
|
49
|
+
detailLevel: number;
|
|
50
|
+
}
|
|
51
|
+
/** Personality profile for a MAGI unit */
|
|
52
|
+
export interface UnitPersonalityProfile {
|
|
53
|
+
unit: MagiUnit;
|
|
54
|
+
vector: BehaviorVector;
|
|
55
|
+
sampleCount: number;
|
|
56
|
+
windowSize: number;
|
|
57
|
+
updatedAt: string;
|
|
58
|
+
}
|
|
59
|
+
/** Interface for pluggable similarity engines */
|
|
60
|
+
export interface ISimilarityEngine {
|
|
61
|
+
computeSimilarity(query: string, documents: string[]): number[];
|
|
62
|
+
}
|
|
63
|
+
/** Strategy variant labels for BERSERK mode */
|
|
64
|
+
export type BerserkStrategyLabel = 'alpha' | 'beta' | 'gamma' | 'delta' | 'epsilon';
|
|
65
|
+
/** A single strategy definition */
|
|
66
|
+
export interface BerserkStrategy {
|
|
67
|
+
label: BerserkStrategyLabel;
|
|
68
|
+
name: string;
|
|
69
|
+
promptPrefix: string;
|
|
70
|
+
}
|
|
71
|
+
/** A candidate opinion from BERSERK parallel execution */
|
|
72
|
+
export interface BerserkCandidate {
|
|
73
|
+
unit: MagiUnit;
|
|
74
|
+
strategy: BerserkStrategyLabel;
|
|
75
|
+
opinion: MagiOpinion;
|
|
76
|
+
fitnessScore: number;
|
|
77
|
+
}
|
|
78
|
+
/** Result of a single BERSERK round */
|
|
79
|
+
export interface BerserkRoundResult {
|
|
80
|
+
roundNumber: number;
|
|
81
|
+
candidates: BerserkCandidate[];
|
|
82
|
+
survivors: BerserkCandidate[];
|
|
83
|
+
consensusReached: boolean;
|
|
84
|
+
decision?: ConsensusDecision;
|
|
85
|
+
}
|
|
86
|
+
/** BERSERK orchestrator configuration */
|
|
87
|
+
export interface BerserkConfig {
|
|
88
|
+
maxRounds: number;
|
|
89
|
+
concurrencyLimit: number;
|
|
90
|
+
survivorCount: number;
|
|
91
|
+
}
|
|
92
|
+
/** Weights for fusion of multiple opinions */
|
|
93
|
+
export interface FusionWeights {
|
|
94
|
+
[unit: string]: number;
|
|
95
|
+
}
|
|
96
|
+
/** A fused opinion derived from multiple unit opinions */
|
|
97
|
+
export interface FusedOpinion extends MagiOpinion {
|
|
98
|
+
isDerived: true;
|
|
99
|
+
fusionWeights: FusionWeights;
|
|
100
|
+
sourceOpinions: MagiUnit[];
|
|
101
|
+
}
|
|
102
|
+
/** Result of an Instrumentality fusion */
|
|
103
|
+
export interface InstrumentalityResult {
|
|
104
|
+
fused: FusedOpinion;
|
|
105
|
+
triggerReason: string;
|
|
106
|
+
roundsBeforeFusion: number;
|
|
107
|
+
tokenCostEstimate: number;
|
|
108
|
+
}
|
|
109
|
+
/** LCL density level (0.0 = no sharing, 1.0 = full sharing) */
|
|
110
|
+
export type LCLDensity = number;
|
|
111
|
+
/** Phase-specific LCL density configuration */
|
|
112
|
+
export interface LCLPhaseConfig {
|
|
113
|
+
'initial-opinion': LCLDensity;
|
|
114
|
+
'cross-examination': LCLDensity;
|
|
115
|
+
'final-vote': LCLDensity;
|
|
116
|
+
}
|
|
117
|
+
/** Types of hallucinations that can be detected */
|
|
118
|
+
export type HallucinationType = 'fabricated-path' | 'abnormal-line-number' | 'vote-reasoning-mismatch' | 'fabricated-reference';
|
|
119
|
+
/** A single hallucination detection report */
|
|
120
|
+
export interface HallucinationReport {
|
|
121
|
+
type: HallucinationType;
|
|
122
|
+
description: string;
|
|
123
|
+
confidence: number;
|
|
124
|
+
location?: string;
|
|
125
|
+
}
|
|
126
|
+
/** Result of LCL contamination analysis */
|
|
127
|
+
export interface LCLContaminationResult {
|
|
128
|
+
unit: MagiUnit;
|
|
129
|
+
reports: HallucinationReport[];
|
|
130
|
+
purified: boolean;
|
|
131
|
+
originalConfidence: number;
|
|
132
|
+
adjustedConfidence: number;
|
|
133
|
+
}
|
|
134
|
+
export interface MemoryDriftWarningEvent {
|
|
135
|
+
unit: MagiUnit;
|
|
136
|
+
asiScore: number;
|
|
137
|
+
threshold: number;
|
|
138
|
+
consecutiveCount: number;
|
|
139
|
+
emittedAt: Date;
|
|
140
|
+
}
|
|
141
|
+
export interface MemoryConsolidatedEvent {
|
|
142
|
+
episodicCount: number;
|
|
143
|
+
patternsExtracted: number;
|
|
144
|
+
strategiesUpdated: number;
|
|
145
|
+
emittedAt: Date;
|
|
146
|
+
}
|
|
147
|
+
export interface BerserkActivatedEvent {
|
|
148
|
+
deliberationId: string;
|
|
149
|
+
round: number;
|
|
150
|
+
candidateCount: number;
|
|
151
|
+
strategies: BerserkStrategyLabel[];
|
|
152
|
+
emittedAt: Date;
|
|
153
|
+
}
|
|
154
|
+
export interface BerserkDeactivatedEvent {
|
|
155
|
+
deliberationId: string;
|
|
156
|
+
totalRounds: number;
|
|
157
|
+
decision: ConsensusDecision;
|
|
158
|
+
emittedAt: Date;
|
|
159
|
+
}
|
|
160
|
+
export interface InstrumentalityTriggeredEvent {
|
|
161
|
+
deliberationId: string;
|
|
162
|
+
reason: string;
|
|
163
|
+
roundsBeforeFusion: number;
|
|
164
|
+
emittedAt: Date;
|
|
165
|
+
}
|
|
166
|
+
export interface FusionCompleteEvent {
|
|
167
|
+
deliberationId: string;
|
|
168
|
+
confidence: number;
|
|
169
|
+
weights: FusionWeights;
|
|
170
|
+
emittedAt: Date;
|
|
171
|
+
}
|
|
172
|
+
export interface LCLContaminationDetectedEvent {
|
|
173
|
+
deliberationId: string;
|
|
174
|
+
unit: MagiUnit;
|
|
175
|
+
hallucinationCount: number;
|
|
176
|
+
types: HallucinationType[];
|
|
177
|
+
emittedAt: Date;
|
|
178
|
+
}
|
|
179
|
+
export interface LCLPurifiedEvent {
|
|
180
|
+
deliberationId: string;
|
|
181
|
+
unit: MagiUnit;
|
|
182
|
+
removedCount: number;
|
|
183
|
+
originalConfidence: number;
|
|
184
|
+
adjustedConfidence: number;
|
|
185
|
+
emittedAt: Date;
|
|
186
|
+
}
|