@elizaos/plugin-directives 1.0.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/dist/index.js ADDED
@@ -0,0 +1,668 @@
1
+ // src/index.ts
2
+ import {
3
+ logger
4
+ } from "@elizaos/core";
5
+
6
+ // src/parsers.ts
7
+ var escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
8
+ function matchLevelDirective(body, names) {
9
+ const namePattern = names.map(escapeRegExp).join("|");
10
+ const match = body.match(new RegExp(`(?:^|\\s)\\/(?:${namePattern})(?=$|\\s|:)`, "i"));
11
+ if (!match || match.index === undefined) {
12
+ return null;
13
+ }
14
+ const start = match.index;
15
+ let end = match.index + match[0].length;
16
+ let i = end;
17
+ while (i < body.length && /\s/.test(body[i])) {
18
+ i += 1;
19
+ }
20
+ if (body[i] === ":") {
21
+ i += 1;
22
+ while (i < body.length && /\s/.test(body[i])) {
23
+ i += 1;
24
+ }
25
+ }
26
+ const argStart = i;
27
+ while (i < body.length && /[A-Za-z0-9-]/.test(body[i])) {
28
+ i += 1;
29
+ }
30
+ const rawLevel = i > argStart ? body.slice(argStart, i) : undefined;
31
+ end = i;
32
+ return { start, end, rawLevel };
33
+ }
34
+ function extractLevelDirective(body, names, normalize) {
35
+ const match = matchLevelDirective(body, names);
36
+ if (!match) {
37
+ return { cleaned: body.trim(), hasDirective: false };
38
+ }
39
+ const rawLevel = match.rawLevel;
40
+ const level = normalize(rawLevel);
41
+ const cleaned = body.slice(0, match.start).concat(" ").concat(body.slice(match.end)).replace(/\s+/g, " ").trim();
42
+ return {
43
+ cleaned,
44
+ level,
45
+ rawLevel,
46
+ hasDirective: true
47
+ };
48
+ }
49
+ function extractSimpleDirective(body, names) {
50
+ const namePattern = names.map(escapeRegExp).join("|");
51
+ const match = body.match(new RegExp(`(?:^|\\s)\\/(?:${namePattern})(?=$|\\s|:)(?:\\s*:\\s*)?`, "i"));
52
+ const cleaned = match ? body.replace(match[0], " ").replace(/\s+/g, " ").trim() : body.trim();
53
+ return {
54
+ cleaned,
55
+ hasDirective: Boolean(match)
56
+ };
57
+ }
58
+ function normalizeThinkLevel(raw) {
59
+ if (!raw)
60
+ return;
61
+ const key = raw.toLowerCase();
62
+ if (["off"].includes(key))
63
+ return "off";
64
+ if (["on", "enable", "enabled"].includes(key))
65
+ return "low";
66
+ if (["min", "minimal"].includes(key))
67
+ return "minimal";
68
+ if (["low", "thinkhard", "think-hard", "think_hard"].includes(key))
69
+ return "low";
70
+ if (["mid", "med", "medium", "thinkharder", "think-harder", "harder"].includes(key))
71
+ return "medium";
72
+ if ([
73
+ "high",
74
+ "ultra",
75
+ "ultrathink",
76
+ "think-hard",
77
+ "thinkhardest",
78
+ "highest",
79
+ "max"
80
+ ].includes(key))
81
+ return "high";
82
+ if (["xhigh", "x-high", "x_high"].includes(key))
83
+ return "xhigh";
84
+ if (["think"].includes(key))
85
+ return "minimal";
86
+ return;
87
+ }
88
+ function normalizeVerboseLevel(raw) {
89
+ if (!raw)
90
+ return;
91
+ const key = raw.toLowerCase();
92
+ if (["off", "false", "no", "0"].includes(key))
93
+ return "off";
94
+ if (["full", "all", "everything"].includes(key))
95
+ return "full";
96
+ if (["on", "minimal", "true", "yes", "1"].includes(key))
97
+ return "on";
98
+ return;
99
+ }
100
+ function normalizeReasoningLevel(raw) {
101
+ if (!raw)
102
+ return;
103
+ const key = raw.toLowerCase();
104
+ if ([
105
+ "off",
106
+ "false",
107
+ "no",
108
+ "0",
109
+ "hide",
110
+ "hidden",
111
+ "disable",
112
+ "disabled"
113
+ ].includes(key))
114
+ return "off";
115
+ if (["on", "true", "yes", "1", "show", "visible", "enable", "enabled"].includes(key))
116
+ return "on";
117
+ if (["stream", "streaming", "draft", "live"].includes(key))
118
+ return "stream";
119
+ return;
120
+ }
121
+ function normalizeElevatedLevel(raw) {
122
+ if (!raw)
123
+ return;
124
+ const key = raw.toLowerCase();
125
+ if (["off", "false", "no", "0"].includes(key))
126
+ return "off";
127
+ if (["full", "auto", "auto-approve", "autoapprove"].includes(key))
128
+ return "full";
129
+ if (["ask", "prompt", "approval", "approve"].includes(key))
130
+ return "ask";
131
+ if (["on", "true", "yes", "1"].includes(key))
132
+ return "on";
133
+ return;
134
+ }
135
+ function normalizeExecHost(raw) {
136
+ if (!raw)
137
+ return;
138
+ const key = raw.toLowerCase();
139
+ if (["sandbox", "sb"].includes(key))
140
+ return "sandbox";
141
+ if (["gateway", "gw", "local"].includes(key))
142
+ return "gateway";
143
+ if (["node", "remote"].includes(key))
144
+ return "node";
145
+ return;
146
+ }
147
+ function normalizeExecSecurity(raw) {
148
+ if (!raw)
149
+ return;
150
+ const key = raw.toLowerCase();
151
+ if (["deny", "none", "off"].includes(key))
152
+ return "deny";
153
+ if (["allowlist", "allow", "list"].includes(key))
154
+ return "allowlist";
155
+ if (["full", "all", "any"].includes(key))
156
+ return "full";
157
+ return;
158
+ }
159
+ function normalizeExecAsk(raw) {
160
+ if (!raw)
161
+ return;
162
+ const key = raw.toLowerCase();
163
+ if (["off", "never", "no"].includes(key))
164
+ return "off";
165
+ if (["on-miss", "miss", "fallback"].includes(key))
166
+ return "on-miss";
167
+ if (["always", "on", "yes"].includes(key))
168
+ return "always";
169
+ return;
170
+ }
171
+ function extractThinkDirective(body) {
172
+ if (!body)
173
+ return { cleaned: "", hasDirective: false };
174
+ const extracted = extractLevelDirective(body, ["thinking", "think", "t"], normalizeThinkLevel);
175
+ return {
176
+ cleaned: extracted.cleaned,
177
+ thinkLevel: extracted.level,
178
+ rawLevel: extracted.rawLevel,
179
+ hasDirective: extracted.hasDirective
180
+ };
181
+ }
182
+ function extractVerboseDirective(body) {
183
+ if (!body)
184
+ return { cleaned: "", hasDirective: false };
185
+ const extracted = extractLevelDirective(body, ["verbose", "v"], normalizeVerboseLevel);
186
+ return {
187
+ cleaned: extracted.cleaned,
188
+ verboseLevel: extracted.level,
189
+ rawLevel: extracted.rawLevel,
190
+ hasDirective: extracted.hasDirective
191
+ };
192
+ }
193
+ function extractReasoningDirective(body) {
194
+ if (!body)
195
+ return { cleaned: "", hasDirective: false };
196
+ const extracted = extractLevelDirective(body, ["reasoning", "reason"], normalizeReasoningLevel);
197
+ return {
198
+ cleaned: extracted.cleaned,
199
+ reasoningLevel: extracted.level,
200
+ rawLevel: extracted.rawLevel,
201
+ hasDirective: extracted.hasDirective
202
+ };
203
+ }
204
+ function extractElevatedDirective(body) {
205
+ if (!body)
206
+ return { cleaned: "", hasDirective: false };
207
+ const extracted = extractLevelDirective(body, ["elevated", "elev"], normalizeElevatedLevel);
208
+ return {
209
+ cleaned: extracted.cleaned,
210
+ elevatedLevel: extracted.level,
211
+ rawLevel: extracted.rawLevel,
212
+ hasDirective: extracted.hasDirective
213
+ };
214
+ }
215
+ function extractStatusDirective(body) {
216
+ if (!body)
217
+ return { cleaned: "", hasDirective: false };
218
+ return extractSimpleDirective(body, ["status"]);
219
+ }
220
+ function extractModelDirective(body, options) {
221
+ if (!body)
222
+ return { cleaned: "", hasDirective: false };
223
+ const modelMatch = body.match(/(?:^|\s)\/model(?:\s*:\s*|\s+)([a-zA-Z0-9_-]+(?:\/[a-zA-Z0-9._-]+)?(?:@[a-zA-Z0-9_-]+)?)/i);
224
+ if (modelMatch) {
225
+ const fullMatch = modelMatch[1];
226
+ const atIndex = fullMatch.indexOf("@");
227
+ const rawModel = atIndex >= 0 ? fullMatch.slice(0, atIndex) : fullMatch;
228
+ const rawProfile = atIndex >= 0 ? fullMatch.slice(atIndex + 1) : undefined;
229
+ const cleaned = body.replace(modelMatch[0], " ").replace(/\s+/g, " ").trim();
230
+ return { cleaned, rawModel, rawProfile, hasDirective: true };
231
+ }
232
+ const simpleMatch = body.match(/(?:^|\s)\/model(?=$|\s|:)/i);
233
+ if (simpleMatch) {
234
+ const cleaned = body.replace(simpleMatch[0], " ").replace(/\s+/g, " ").trim();
235
+ return { cleaned, hasDirective: true };
236
+ }
237
+ if (options?.aliases?.length) {
238
+ for (const alias of options.aliases) {
239
+ const aliasPattern = new RegExp(`(?:^|\\s)/${escapeRegExp(alias)}(?=$|\\s)`, "i");
240
+ const aliasMatch = body.match(aliasPattern);
241
+ if (aliasMatch) {
242
+ const cleaned = body.replace(aliasMatch[0], " ").replace(/\s+/g, " ").trim();
243
+ return { cleaned, rawModel: alias, hasDirective: true };
244
+ }
245
+ }
246
+ }
247
+ return { cleaned: body.trim(), hasDirective: false };
248
+ }
249
+ function extractExecDirective(body) {
250
+ if (!body) {
251
+ return {
252
+ cleaned: "",
253
+ hasExecOptions: false,
254
+ invalidHost: false,
255
+ invalidSecurity: false,
256
+ invalidAsk: false,
257
+ invalidNode: false,
258
+ hasDirective: false
259
+ };
260
+ }
261
+ const execMatch = body.match(/(?:^|\s)\/exec(?:\s+([^\/\n]+))?(?=$|\s|\/)/i);
262
+ if (!execMatch) {
263
+ return {
264
+ cleaned: body.trim(),
265
+ hasExecOptions: false,
266
+ invalidHost: false,
267
+ invalidSecurity: false,
268
+ invalidAsk: false,
269
+ invalidNode: false,
270
+ hasDirective: false
271
+ };
272
+ }
273
+ const args = execMatch[1]?.trim() ?? "";
274
+ const cleaned = body.replace(execMatch[0], " ").replace(/\s+/g, " ").trim();
275
+ let rawExecHost;
276
+ let rawExecSecurity;
277
+ let rawExecAsk;
278
+ let rawExecNode;
279
+ const kvPattern = /(\w+)\s*=\s*([^\s]+)/g;
280
+ let match;
281
+ while ((match = kvPattern.exec(args)) !== null) {
282
+ const key = match[1].toLowerCase();
283
+ const value = match[2];
284
+ if (key === "host")
285
+ rawExecHost = value;
286
+ else if (key === "security")
287
+ rawExecSecurity = value;
288
+ else if (key === "ask")
289
+ rawExecAsk = value;
290
+ else if (key === "node")
291
+ rawExecNode = value;
292
+ }
293
+ const execHost = normalizeExecHost(rawExecHost);
294
+ const execSecurity = normalizeExecSecurity(rawExecSecurity);
295
+ const execAsk = normalizeExecAsk(rawExecAsk);
296
+ return {
297
+ cleaned,
298
+ execHost,
299
+ execSecurity,
300
+ execAsk,
301
+ execNode: rawExecNode,
302
+ rawExecHost,
303
+ rawExecSecurity,
304
+ rawExecAsk,
305
+ rawExecNode,
306
+ hasExecOptions: Boolean(rawExecHost || rawExecSecurity || rawExecAsk || rawExecNode),
307
+ invalidHost: Boolean(rawExecHost && !execHost),
308
+ invalidSecurity: Boolean(rawExecSecurity && !execSecurity),
309
+ invalidAsk: Boolean(rawExecAsk && !execAsk),
310
+ invalidNode: false,
311
+ hasDirective: true
312
+ };
313
+ }
314
+
315
+ // src/index.ts
316
+ var sessionStates = new Map;
317
+ function getDefaultState() {
318
+ return {
319
+ thinking: "low",
320
+ verbose: "off",
321
+ reasoning: "off",
322
+ elevated: "off",
323
+ exec: {},
324
+ model: {}
325
+ };
326
+ }
327
+ function getDirectiveState(roomId) {
328
+ return sessionStates.get(roomId) ?? getDefaultState();
329
+ }
330
+ function setDirectiveState(roomId, state) {
331
+ sessionStates.set(roomId, state);
332
+ }
333
+ function clearDirectiveState(roomId) {
334
+ sessionStates.delete(roomId);
335
+ }
336
+ function parseDirectives(body, options) {
337
+ const {
338
+ cleaned: thinkCleaned,
339
+ thinkLevel,
340
+ rawLevel: rawThinkLevel,
341
+ hasDirective: hasThinkDirective
342
+ } = extractThinkDirective(body);
343
+ const {
344
+ cleaned: verboseCleaned,
345
+ verboseLevel,
346
+ rawLevel: rawVerboseLevel,
347
+ hasDirective: hasVerboseDirective
348
+ } = extractVerboseDirective(thinkCleaned);
349
+ const {
350
+ cleaned: reasoningCleaned,
351
+ reasoningLevel,
352
+ rawLevel: rawReasoningLevel,
353
+ hasDirective: hasReasoningDirective
354
+ } = extractReasoningDirective(verboseCleaned);
355
+ const {
356
+ cleaned: elevatedCleaned,
357
+ elevatedLevel,
358
+ rawLevel: rawElevatedLevel,
359
+ hasDirective: hasElevatedDirective
360
+ } = options?.disableElevated ? {
361
+ cleaned: reasoningCleaned,
362
+ elevatedLevel: undefined,
363
+ rawLevel: undefined,
364
+ hasDirective: false
365
+ } : extractElevatedDirective(reasoningCleaned);
366
+ const {
367
+ cleaned: execCleaned,
368
+ execHost,
369
+ execSecurity,
370
+ execAsk,
371
+ execNode,
372
+ rawExecHost,
373
+ rawExecSecurity,
374
+ rawExecAsk,
375
+ rawExecNode,
376
+ hasExecOptions,
377
+ invalidHost: invalidExecHost,
378
+ invalidSecurity: invalidExecSecurity,
379
+ invalidAsk: invalidExecAsk,
380
+ invalidNode: invalidExecNode,
381
+ hasDirective: hasExecDirective
382
+ } = extractExecDirective(elevatedCleaned);
383
+ const allowStatusDirective = options?.allowStatusDirective !== false;
384
+ const { cleaned: statusCleaned, hasDirective: hasStatusDirective } = allowStatusDirective ? extractStatusDirective(execCleaned) : { cleaned: execCleaned, hasDirective: false };
385
+ const {
386
+ cleaned: modelCleaned,
387
+ rawModel,
388
+ rawProfile,
389
+ hasDirective: hasModelDirective
390
+ } = extractModelDirective(statusCleaned, {
391
+ aliases: options?.modelAliases
392
+ });
393
+ const hasAnyDirective = hasThinkDirective || hasVerboseDirective || hasReasoningDirective || hasElevatedDirective || hasExecDirective || hasModelDirective;
394
+ const directivesOnly = hasAnyDirective && modelCleaned.trim().length === 0;
395
+ return {
396
+ cleanedText: modelCleaned,
397
+ directivesOnly,
398
+ hasThinkDirective,
399
+ thinkLevel,
400
+ rawThinkLevel,
401
+ hasVerboseDirective,
402
+ verboseLevel,
403
+ rawVerboseLevel,
404
+ hasReasoningDirective,
405
+ reasoningLevel,
406
+ rawReasoningLevel,
407
+ hasElevatedDirective,
408
+ elevatedLevel,
409
+ rawElevatedLevel,
410
+ hasExecDirective,
411
+ execHost,
412
+ execSecurity,
413
+ execAsk,
414
+ execNode,
415
+ rawExecHost,
416
+ rawExecSecurity,
417
+ rawExecAsk,
418
+ rawExecNode,
419
+ hasExecOptions,
420
+ invalidExecHost,
421
+ invalidExecSecurity,
422
+ invalidExecAsk,
423
+ invalidExecNode,
424
+ hasStatusDirective,
425
+ hasModelDirective,
426
+ rawModelDirective: rawModel,
427
+ rawModelProfile: rawProfile
428
+ };
429
+ }
430
+ function applyDirectives(roomId, directives, persist = true) {
431
+ const current = getDirectiveState(roomId);
432
+ const updated = { ...current };
433
+ if (directives.hasThinkDirective && directives.thinkLevel) {
434
+ updated.thinking = directives.thinkLevel;
435
+ }
436
+ if (directives.hasVerboseDirective && directives.verboseLevel) {
437
+ updated.verbose = directives.verboseLevel;
438
+ }
439
+ if (directives.hasReasoningDirective && directives.reasoningLevel) {
440
+ updated.reasoning = directives.reasoningLevel;
441
+ }
442
+ if (directives.hasElevatedDirective && directives.elevatedLevel) {
443
+ updated.elevated = directives.elevatedLevel;
444
+ }
445
+ if (directives.hasExecDirective) {
446
+ updated.exec = {
447
+ ...updated.exec,
448
+ ...directives.execHost && { host: directives.execHost },
449
+ ...directives.execSecurity && { security: directives.execSecurity },
450
+ ...directives.execAsk && { ask: directives.execAsk },
451
+ ...directives.execNode && { node: directives.execNode }
452
+ };
453
+ }
454
+ if (directives.hasModelDirective && directives.rawModelDirective) {
455
+ const parts = directives.rawModelDirective.split("/");
456
+ if (parts.length === 2) {
457
+ updated.model = {
458
+ provider: parts[0],
459
+ model: parts[1],
460
+ authProfile: directives.rawModelProfile
461
+ };
462
+ } else {
463
+ updated.model = {
464
+ model: directives.rawModelDirective,
465
+ authProfile: directives.rawModelProfile
466
+ };
467
+ }
468
+ }
469
+ if (persist) {
470
+ setDirectiveState(roomId, updated);
471
+ }
472
+ return updated;
473
+ }
474
+ function formatDirectiveState(state) {
475
+ const lines = [];
476
+ lines.push(`Thinking: ${state.thinking}`);
477
+ lines.push(`Verbose: ${state.verbose}`);
478
+ lines.push(`Reasoning: ${state.reasoning}`);
479
+ lines.push(`Elevated: ${state.elevated}`);
480
+ if (state.model.provider || state.model.model) {
481
+ const modelStr = state.model.provider ? `${state.model.provider}/${state.model.model}` : state.model.model;
482
+ lines.push(`Model: ${modelStr}${state.model.authProfile ? ` @${state.model.authProfile}` : ""}`);
483
+ }
484
+ return lines.join(`
485
+ `);
486
+ }
487
+ function formatDirectiveAcknowledgment(directives) {
488
+ const changes = [];
489
+ if (directives.hasThinkDirective) {
490
+ changes.push(`Thinking: ${directives.thinkLevel ?? "status"}`);
491
+ }
492
+ if (directives.hasVerboseDirective) {
493
+ changes.push(`Verbose: ${directives.verboseLevel ?? "status"}`);
494
+ }
495
+ if (directives.hasReasoningDirective) {
496
+ changes.push(`Reasoning: ${directives.reasoningLevel ?? "status"}`);
497
+ }
498
+ if (directives.hasElevatedDirective) {
499
+ changes.push(`Elevated: ${directives.elevatedLevel ?? "status"}`);
500
+ }
501
+ if (directives.hasModelDirective) {
502
+ changes.push(`Model: ${directives.rawModelDirective ?? "status"}`);
503
+ }
504
+ return changes.length > 0 ? `✓ ${changes.join(", ")}` : "No changes applied";
505
+ }
506
+ var directiveStateProvider = {
507
+ name: "DIRECTIVE_STATE",
508
+ description: "Current directive levels (thinking, verbose, model, etc.)",
509
+ async get(runtime, message, _state) {
510
+ const roomId = message.roomId;
511
+ const directives = getDirectiveState(roomId);
512
+ return {
513
+ text: formatDirectiveState(directives),
514
+ values: {
515
+ thinkingLevel: directives.thinking,
516
+ verboseLevel: directives.verbose,
517
+ reasoningLevel: directives.reasoning,
518
+ elevatedLevel: directives.elevated,
519
+ modelProvider: directives.model.provider ?? "",
520
+ modelName: directives.model.model ?? "",
521
+ isElevated: directives.elevated !== "off"
522
+ },
523
+ data: { directives }
524
+ };
525
+ }
526
+ };
527
+ var directivesPlugin = {
528
+ name: "directives",
529
+ description: "Inline directive parsing (@think, @model, @verbose, etc.) for controlling agent behavior",
530
+ providers: [directiveStateProvider],
531
+ config: {
532
+ DEFAULT_THINKING: "low",
533
+ DEFAULT_VERBOSE: "off",
534
+ ALLOW_ELEVATED: "true",
535
+ ALLOW_EXEC: "false"
536
+ },
537
+ tests: [
538
+ {
539
+ name: "directive-parsing",
540
+ tests: [
541
+ {
542
+ name: "Parse think directive",
543
+ fn: async (_runtime) => {
544
+ const result = parseDirectives("/think:high hello world");
545
+ if (!result.hasThinkDirective) {
546
+ throw new Error("Should detect think directive");
547
+ }
548
+ if (result.thinkLevel !== "high") {
549
+ throw new Error(`Expected 'high', got '${result.thinkLevel}'`);
550
+ }
551
+ if (result.cleanedText !== "hello world") {
552
+ throw new Error(`Expected 'hello world', got '${result.cleanedText}'`);
553
+ }
554
+ logger.success("Think directive parsed correctly");
555
+ }
556
+ },
557
+ {
558
+ name: "Parse verbose directive",
559
+ fn: async (_runtime) => {
560
+ const result = parseDirectives("/v on test message");
561
+ if (!result.hasVerboseDirective) {
562
+ throw new Error("Should detect verbose directive");
563
+ }
564
+ if (result.verboseLevel !== "on") {
565
+ throw new Error(`Expected 'on', got '${result.verboseLevel}'`);
566
+ }
567
+ logger.success("Verbose directive parsed correctly");
568
+ }
569
+ },
570
+ {
571
+ name: "Parse model directive",
572
+ fn: async (_runtime) => {
573
+ const result = parseDirectives("/model anthropic/claude-3-opus what is 2+2");
574
+ if (!result.hasModelDirective) {
575
+ throw new Error("Should detect model directive");
576
+ }
577
+ if (result.rawModelDirective !== "anthropic/claude-3-opus") {
578
+ throw new Error(`Expected 'anthropic/claude-3-opus', got '${result.rawModelDirective}'`);
579
+ }
580
+ logger.success("Model directive parsed correctly");
581
+ }
582
+ },
583
+ {
584
+ name: "Detect directive-only message",
585
+ fn: async (_runtime) => {
586
+ const result = parseDirectives("/think:high /verbose on");
587
+ if (!result.directivesOnly) {
588
+ throw new Error("Should detect directive-only message");
589
+ }
590
+ logger.success("Directive-only detection works correctly");
591
+ }
592
+ },
593
+ {
594
+ name: "Parse multiple directives",
595
+ fn: async (_runtime) => {
596
+ const result = parseDirectives("/think:medium /v full /elevated on hello");
597
+ if (!result.hasThinkDirective || !result.hasVerboseDirective || !result.hasElevatedDirective) {
598
+ throw new Error("Should detect all directives");
599
+ }
600
+ if (result.thinkLevel !== "medium") {
601
+ throw new Error(`Expected 'medium', got '${result.thinkLevel}'`);
602
+ }
603
+ if (result.verboseLevel !== "full") {
604
+ throw new Error(`Expected 'full', got '${result.verboseLevel}'`);
605
+ }
606
+ if (result.elevatedLevel !== "on") {
607
+ throw new Error(`Expected 'on', got '${result.elevatedLevel}'`);
608
+ }
609
+ if (result.cleanedText !== "hello") {
610
+ throw new Error(`Expected 'hello', got '${result.cleanedText}'`);
611
+ }
612
+ logger.success("Multiple directives parsed correctly");
613
+ }
614
+ },
615
+ {
616
+ name: "Session state management",
617
+ fn: async (_runtime) => {
618
+ const roomId = "test-room-123";
619
+ clearDirectiveState(roomId);
620
+ const directives = parseDirectives("/think:high /verbose on");
621
+ applyDirectives(roomId, directives);
622
+ const state = getDirectiveState(roomId);
623
+ if (state.thinking !== "high") {
624
+ throw new Error(`Expected thinking 'high', got '${state.thinking}'`);
625
+ }
626
+ if (state.verbose !== "on") {
627
+ throw new Error(`Expected verbose 'on', got '${state.verbose}'`);
628
+ }
629
+ clearDirectiveState(roomId);
630
+ logger.success("Session state management works correctly");
631
+ }
632
+ }
633
+ ]
634
+ }
635
+ ],
636
+ async init(_config, runtime) {
637
+ logger.log("[plugin-directives] Initializing directive parser");
638
+ }
639
+ };
640
+ var src_default = directivesPlugin;
641
+ export {
642
+ setDirectiveState,
643
+ parseDirectives,
644
+ normalizeVerboseLevel,
645
+ normalizeThinkLevel,
646
+ normalizeReasoningLevel,
647
+ normalizeExecSecurity,
648
+ normalizeExecHost,
649
+ normalizeExecAsk,
650
+ normalizeElevatedLevel,
651
+ getDirectiveState,
652
+ formatDirectiveState,
653
+ formatDirectiveAcknowledgment,
654
+ extractVerboseDirective,
655
+ extractThinkDirective,
656
+ extractStatusDirective,
657
+ extractReasoningDirective,
658
+ extractModelDirective,
659
+ extractExecDirective,
660
+ extractElevatedDirective,
661
+ directivesPlugin,
662
+ directiveStateProvider,
663
+ src_default as default,
664
+ clearDirectiveState,
665
+ applyDirectives
666
+ };
667
+
668
+ //# debugId=4600B3776B5B382264756E2164756E21