adaptive-bitmask 1.0.0-rc.1

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.
@@ -0,0 +1,123 @@
1
+ import { S as SchemaManager, C as Coordinator, A as Arbiter, b as CoordinatorConfig, c as ArbiterConfig, D as Decision, d as ArbiterResult } from '../coordinator-Df48t6yJ.js';
2
+ import * as ai from 'ai';
3
+ import { LanguageModelV1Middleware } from 'ai';
4
+ import { z } from 'zod';
5
+
6
+ /**
7
+ * CoordinationSession — Lifecycle manager for bitmask-based agent coordination.
8
+ *
9
+ * Wraps SchemaManager + Coordinator + Arbiter into a single object
10
+ * that AI SDK tools and middleware can reference.
11
+ */
12
+
13
+ interface CoordinationSessionConfig {
14
+ /** Initial feature vocabulary to register. */
15
+ features: string[];
16
+ /** Prefix for emergency features. Default: 'EMERGENCY_' */
17
+ emergencyPrefix?: string;
18
+ /** Explicit emergency features (alternative to prefix). */
19
+ emergencyFeatures?: string[];
20
+ /** Coordinator configuration overrides. */
21
+ coordinatorConfig?: Partial<CoordinatorConfig>;
22
+ /** Arbiter configuration overrides. */
23
+ arbiterConfig?: Partial<ArbiterConfig>;
24
+ }
25
+ interface ReportResult {
26
+ accepted: boolean;
27
+ mapped: number;
28
+ unmapped: number;
29
+ }
30
+ interface DecisionResult {
31
+ decision: Decision;
32
+ aggregatedFeatures: string[];
33
+ confidence: Map<number, number>;
34
+ result: ArbiterResult;
35
+ }
36
+ declare class CoordinationSession {
37
+ readonly schema: SchemaManager;
38
+ readonly coordinator: Coordinator;
39
+ readonly arbiter: Arbiter;
40
+ private readonly _agentIds;
41
+ constructor(config: CoordinationSessionConfig);
42
+ /** Deterministic agent ID: FNV-1a hash of name → uint32. */
43
+ agentId(name: string): number;
44
+ /** Start a new coordination round. Clears the coordinator buffer. */
45
+ startRound(): void;
46
+ /** Encode features + create message + receive in one call. */
47
+ report(agentName: string, features: string[]): ReportResult;
48
+ /** Aggregate current buffer + score via arbiter. */
49
+ decide(): DecisionResult;
50
+ }
51
+
52
+ declare function createCoordinationTools(session: CoordinationSession): {
53
+ reportObservation: ai.Tool<z.ZodObject<{
54
+ agentName: z.ZodString;
55
+ features: z.ZodArray<z.ZodString, "many">;
56
+ }, "strip", z.ZodTypeAny, {
57
+ agentName: string;
58
+ features: string[];
59
+ }, {
60
+ agentName: string;
61
+ features: string[];
62
+ }>, {
63
+ accepted: boolean;
64
+ mapped: number;
65
+ unmapped: number;
66
+ }> & {
67
+ execute: (args: {
68
+ agentName: string;
69
+ features: string[];
70
+ }, options: ai.ToolExecutionOptions) => PromiseLike<{
71
+ accepted: boolean;
72
+ mapped: number;
73
+ unmapped: number;
74
+ }>;
75
+ };
76
+ getConsensus: ai.Tool<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, {
77
+ features: string[];
78
+ confidence: Record<string, number>;
79
+ agentCount: number;
80
+ }> & {
81
+ execute: (args: {}, options: ai.ToolExecutionOptions) => PromiseLike<{
82
+ features: string[];
83
+ confidence: Record<string, number>;
84
+ agentCount: number;
85
+ }>;
86
+ };
87
+ requestDecision: ai.Tool<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, {
88
+ decision: Decision;
89
+ score: number;
90
+ features: string[];
91
+ hasEmergency: boolean;
92
+ }> & {
93
+ execute: (args: {}, options: ai.ToolExecutionOptions) => PromiseLike<{
94
+ decision: Decision;
95
+ score: number;
96
+ features: string[];
97
+ hasEmergency: boolean;
98
+ }>;
99
+ };
100
+ };
101
+
102
+ /**
103
+ * Coordination middleware for the Vercel AI SDK.
104
+ *
105
+ * Optionally injects consensus state into the system prompt and/or
106
+ * auto-encodes tool call names as bitmask observations.
107
+ */
108
+
109
+ interface CoordinationMiddlewareOptions {
110
+ /** Inject current consensus into system prompt before each LLM call. Default: false. */
111
+ injectConsensus?: boolean;
112
+ /**
113
+ * Auto-encode tool call names as bitmask observations after generation. Default: false.
114
+ * When enabled, tool calls whose names match registered schema features are
115
+ * automatically reported to the coordinator. Requires agentName.
116
+ */
117
+ autoEncodeToolCalls?: boolean;
118
+ /** Required when autoEncodeToolCalls is true. Identifies this agent in the coordinator. */
119
+ agentName?: string;
120
+ }
121
+ declare function createCoordinationMiddleware(session: CoordinationSession, options?: CoordinationMiddlewareOptions): LanguageModelV1Middleware;
122
+
123
+ export { type CoordinationMiddlewareOptions, CoordinationSession, type CoordinationSessionConfig, type DecisionResult, type ReportResult, createCoordinationMiddleware, createCoordinationTools };