@principles/core 1.240.11 → 1.240.12
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/prompt-builder/__tests__/attitude-directive.test.d.ts +2 -0
- package/dist/prompt-builder/__tests__/attitude-directive.test.d.ts.map +1 -0
- package/dist/prompt-builder/__tests__/attitude-directive.test.js +49 -0
- package/dist/prompt-builder/__tests__/attitude-directive.test.js.map +1 -0
- package/dist/prompt-builder/__tests__/correction-cue.test.d.ts +2 -0
- package/dist/prompt-builder/__tests__/correction-cue.test.d.ts.map +1 -0
- package/dist/prompt-builder/__tests__/correction-cue.test.js +61 -0
- package/dist/prompt-builder/__tests__/correction-cue.test.js.map +1 -0
- package/dist/prompt-builder/__tests__/message-extraction.test.d.ts +2 -0
- package/dist/prompt-builder/__tests__/message-extraction.test.d.ts.map +1 -0
- package/dist/prompt-builder/__tests__/message-extraction.test.js +90 -0
- package/dist/prompt-builder/__tests__/message-extraction.test.js.map +1 -0
- package/dist/prompt-builder/__tests__/minimal-trigger.test.d.ts +2 -0
- package/dist/prompt-builder/__tests__/minimal-trigger.test.d.ts.map +1 -0
- package/dist/prompt-builder/__tests__/minimal-trigger.test.js +45 -0
- package/dist/prompt-builder/__tests__/minimal-trigger.test.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attitude-directive.test.d.ts","sourceRoot":"","sources":["../../../src/prompt-builder/__tests__/attitude-directive.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { buildAttitudeDirective } from '../attitude-directive.js';
|
|
3
|
+
describe('attitude-directive', () => {
|
|
4
|
+
describe('buildAttitudeDirective', () => {
|
|
5
|
+
it('returns HUMBLE_RECOVERY mode when GFI >= 70', () => {
|
|
6
|
+
const result = buildAttitudeDirective(70);
|
|
7
|
+
expect(result).toContain('SYSTEM_MODE: HUMBLE_RECOVERY');
|
|
8
|
+
expect(result).toContain('Severe system friction');
|
|
9
|
+
expect(result).toContain('GFI: 70');
|
|
10
|
+
expect(result).toContain('HUMBLE_RECOVERY');
|
|
11
|
+
});
|
|
12
|
+
it('returns HUMBLE_RECOVERY mode for high GFI values', () => {
|
|
13
|
+
const result = buildAttitudeDirective(95);
|
|
14
|
+
expect(result).toContain('SYSTEM_MODE: HUMBLE_RECOVERY');
|
|
15
|
+
expect(result).toContain('GFI: 95');
|
|
16
|
+
});
|
|
17
|
+
it('returns CONCILIATORY mode when GFI >= 40 and < 70', () => {
|
|
18
|
+
const result = buildAttitudeDirective(40);
|
|
19
|
+
expect(result).toContain('SYSTEM_MODE: CONCILIATORY');
|
|
20
|
+
expect(result).toContain('Moderate friction');
|
|
21
|
+
expect(result).toContain('GFI: 40');
|
|
22
|
+
});
|
|
23
|
+
it('returns CONCILIATORY mode for mid-range GFI values', () => {
|
|
24
|
+
const result = buildAttitudeDirective(55);
|
|
25
|
+
expect(result).toContain('SYSTEM_MODE: CONCILIATORY');
|
|
26
|
+
expect(result).toContain('GFI: 55');
|
|
27
|
+
});
|
|
28
|
+
it('returns EFFICIENT mode when GFI < 40', () => {
|
|
29
|
+
const result = buildAttitudeDirective(39);
|
|
30
|
+
expect(result).toContain('SYSTEM_MODE: EFFICIENT');
|
|
31
|
+
expect(result).toContain('System healthy');
|
|
32
|
+
expect(result).toContain('GFI: 39');
|
|
33
|
+
});
|
|
34
|
+
it('returns EFFICIENT mode for low GFI values', () => {
|
|
35
|
+
const result = buildAttitudeDirective(0);
|
|
36
|
+
expect(result).toContain('SYSTEM_MODE: EFFICIENT');
|
|
37
|
+
expect(result).toContain('GFI: 0');
|
|
38
|
+
});
|
|
39
|
+
it('returns EFFICIENT mode for zero GFI', () => {
|
|
40
|
+
const result = buildAttitudeDirective(0);
|
|
41
|
+
expect(result).toContain('SYSTEM_MODE: EFFICIENT');
|
|
42
|
+
});
|
|
43
|
+
it('formats GFI as integer', () => {
|
|
44
|
+
const result = buildAttitudeDirective(42.5);
|
|
45
|
+
expect(result).toContain('GFI: 43');
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
//# sourceMappingURL=attitude-directive.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attitude-directive.test.js","sourceRoot":"","sources":["../../../src/prompt-builder/__tests__/attitude-directive.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;QACtC,EAAE,CAAC,6CAA6C,EAAE,GAAG,EAAE;YACrD,MAAM,MAAM,GAAG,sBAAsB,CAAC,EAAE,CAAC,CAAC;YAC1C,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,8BAA8B,CAAC,CAAC;YACzD,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,wBAAwB,CAAC,CAAC;YACnD,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;YACpC,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;QAC9C,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,kDAAkD,EAAE,GAAG,EAAE;YAC1D,MAAM,MAAM,GAAG,sBAAsB,CAAC,EAAE,CAAC,CAAC;YAC1C,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,8BAA8B,CAAC,CAAC;YACzD,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,mDAAmD,EAAE,GAAG,EAAE;YAC3D,MAAM,MAAM,GAA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M,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,wBAAwB,CAAC,CAAC;QACrD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,wBAAwB,EAAE,GAAG,EAAE;YAChC,MAAM,MAAM,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAC;YAC5C,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"correction-cue.test.d.ts","sourceRoot":"","sources":["../../../src/prompt-builder/__tests__/correction-cue.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { detectCorrectionCue } from '../correction-cue.js';
|
|
3
|
+
describe('correction-cue detection', () => {
|
|
4
|
+
describe('detectCorrectionCue', () => {
|
|
5
|
+
it('detects Chinese correction cues', () => {
|
|
6
|
+
expect(detectCorrectionCue('不是这个')).toBe('不是这个');
|
|
7
|
+
expect(detectCorrectionCue('不对')).toBe('不对');
|
|
8
|
+
expect(detectCorrectionCue('错了')).toBe('错了');
|
|
9
|
+
expect(detectCorrectionCue('重新来')).toBe('重新来');
|
|
10
|
+
expect(detectCorrectionCue('再试一次')).toBe('再试一次');
|
|
11
|
+
});
|
|
12
|
+
it('detects English correction cues', () => {
|
|
13
|
+
expect(detectCorrectionCue('you are wrong')).toBe('you are wrong');
|
|
14
|
+
expect(detectCorrectionCue('wrong file')).toBe('wrong file');
|
|
15
|
+
expect(detectCorrectionCue('not this')).toBe('not this');
|
|
16
|
+
expect(detectCorrectionCue('redo')).toBe('redo');
|
|
17
|
+
expect(detectCorrectionCue('try again')).toBe('try again');
|
|
18
|
+
expect(detectCorrectionCue('again')).toBe('again');
|
|
19
|
+
});
|
|
20
|
+
it('normalizes whitespace and casing', () => {
|
|
21
|
+
expect(detectCorrectionCue(' 不对 ')).toBe('不对');
|
|
22
|
+
expect(detectCorrectionCue('WRONG FILE')).toBe('wrong file');
|
|
23
|
+
expect(detectCorrectionCue('Try Again')).toBe('try again');
|
|
24
|
+
});
|
|
25
|
+
it('removes punctuation', () => {
|
|
26
|
+
expect(detectCorrectionCue('不对!')).toBe('不对');
|
|
27
|
+
expect(detectCorrectionCue('错了。')).toBe('错了');
|
|
28
|
+
expect(detectCorrectionCue('wrong file!')).toBe('wrong file');
|
|
29
|
+
expect(detectCorrectionCue('not this, please')).toBe('not this');
|
|
30
|
+
expect(detectCorrectionCue('redo.')).toBe('redo');
|
|
31
|
+
});
|
|
32
|
+
it('returns null for non-correction text', () => {
|
|
33
|
+
expect(detectCorrectionCue('好的')).toBeNull();
|
|
34
|
+
expect(detectCorrectionCue('可以')).toBeNull();
|
|
35
|
+
expect(detectCorrectionCue('继续')).toBeNull();
|
|
36
|
+
expect(detectCorrectionCue('OK')).toBeNull();
|
|
37
|
+
expect(detectCorrectionCue('yes')).toBeNull();
|
|
38
|
+
expect(detectCorrectionCue('correct answer')).toBeNull();
|
|
39
|
+
});
|
|
40
|
+
it('returns null for empty string', () => {
|
|
41
|
+
expect(detectCorrectionCue('')).toBeNull();
|
|
42
|
+
});
|
|
43
|
+
it('returns null for whitespace-only string', () => {
|
|
44
|
+
expect(detectCorrectionCue(' ')).toBeNull();
|
|
45
|
+
expect(detectCorrectionCue('\t\n')).toBeNull();
|
|
46
|
+
});
|
|
47
|
+
it('matches first cue in array order when multiple cues overlap', () => {
|
|
48
|
+
expect(detectCorrectionCue('搞错了')).toBe('错了');
|
|
49
|
+
expect(detectCorrectionCue('理解错了')).toBe('错了');
|
|
50
|
+
expect(detectCorrectionCue('你理解错了')).toBe('错了');
|
|
51
|
+
expect(detectCorrectionCue('please redo')).toBe('redo');
|
|
52
|
+
expect(detectCorrectionCue('please try again')).toBe('try again');
|
|
53
|
+
});
|
|
54
|
+
it('detects cue within longer text', () => {
|
|
55
|
+
expect(detectCorrectionCue('我想说的不是这个,你搞错了')).toBe('不是这个');
|
|
56
|
+
expect(detectCorrectionCue('这个不对,请重新来')).toBe('不对');
|
|
57
|
+
expect(detectCorrectionCue('Please try again with different parameters')).toBe('try again');
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
//# sourceMappingURL=correction-cue.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"correction-cue.test.js","sourceRoot":"","sources":["../../../src/prompt-builder/__tests__/correction-cue.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACxC,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;QACnC,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE;YACzC,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACjD,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC7C,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC7C,MAAM,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC/C,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACnD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE;YACzC,MAAM,CAAC,mBAAmB,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;YACnE,MAA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CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAChD,MAAM,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACxD,MAAM,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACpE,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE;YACxC,MAAM,CAAC,mBAAmB,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC1D,MAAM,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACpD,MAAM,CAAC,mBAAmB,CAAC,4CAA4C,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC9F,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-extraction.test.d.ts","sourceRoot":"","sources":["../../../src/prompt-builder/__tests__/message-extraction.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { extractMessageContent } from '../message-extraction.js';
|
|
3
|
+
describe('message-extraction', () => {
|
|
4
|
+
describe('extractMessageContent', () => {
|
|
5
|
+
it('returns string as-is', () => {
|
|
6
|
+
expect(extractMessageContent('hello world')).toBe('hello world');
|
|
7
|
+
});
|
|
8
|
+
it('returns empty string for null', () => {
|
|
9
|
+
expect(extractMessageContent(null)).toBe('');
|
|
10
|
+
});
|
|
11
|
+
it('returns empty string for undefined', () => {
|
|
12
|
+
expect(extractMessageContent(undefined)).toBe('');
|
|
13
|
+
});
|
|
14
|
+
it('returns empty string for non-object primitives', () => {
|
|
15
|
+
expect(extractMessageContent(123)).toBe('');
|
|
16
|
+
expect(extractMessageContent(true)).toBe('');
|
|
17
|
+
expect(extractMessageContent(Symbol('test'))).toBe('');
|
|
18
|
+
});
|
|
19
|
+
it('extracts string content from object', () => {
|
|
20
|
+
expect(extractMessageContent({ content: 'hello' })).toBe('hello');
|
|
21
|
+
});
|
|
22
|
+
it('returns empty string when content is missing', () => {
|
|
23
|
+
expect(extractMessageContent({})).toBe('');
|
|
24
|
+
});
|
|
25
|
+
it('returns empty string when content is not string', () => {
|
|
26
|
+
expect(extractMessageContent({ content: 123 })).toBe('');
|
|
27
|
+
expect(extractMessageContent({ content: null })).toBe('');
|
|
28
|
+
expect(extractMessageContent({ content: {} })).toBe('');
|
|
29
|
+
});
|
|
30
|
+
it('extracts text from array content with text parts', () => {
|
|
31
|
+
const message = {
|
|
32
|
+
content: [
|
|
33
|
+
{ type: 'text', text: 'hello' },
|
|
34
|
+
{ type: 'text', text: 'world' },
|
|
35
|
+
],
|
|
36
|
+
};
|
|
37
|
+
expect(extractMessageContent(message)).toBe('hello\nworld');
|
|
38
|
+
});
|
|
39
|
+
it('filters non-text parts from array content', () => {
|
|
40
|
+
const message = {
|
|
41
|
+
content: [
|
|
42
|
+
{ type: 'text', text: 'hello' },
|
|
43
|
+
{ type: 'image', url: 'http://example.com' },
|
|
44
|
+
{ type: 'text', text: 'world' },
|
|
45
|
+
],
|
|
46
|
+
};
|
|
47
|
+
expect(extractMessageContent(message)).toBe('hello\nworld');
|
|
48
|
+
});
|
|
49
|
+
it('handles empty text in array parts', () => {
|
|
50
|
+
const message = {
|
|
51
|
+
content: [
|
|
52
|
+
{ type: 'text', text: '' },
|
|
53
|
+
{ type: 'text', text: 'hello' },
|
|
54
|
+
],
|
|
55
|
+
};
|
|
56
|
+
expect(extractMessageContent(message)).toBe('hello');
|
|
57
|
+
});
|
|
58
|
+
it('handles missing text property in text parts', () => {
|
|
59
|
+
const message = {
|
|
60
|
+
content: [
|
|
61
|
+
{ type: 'text' },
|
|
62
|
+
{ type: 'text', text: 'hello' },
|
|
63
|
+
],
|
|
64
|
+
};
|
|
65
|
+
expect(extractMessageContent(message)).toBe('hello');
|
|
66
|
+
});
|
|
67
|
+
it('trims result from array content', () => {
|
|
68
|
+
const message = {
|
|
69
|
+
content: [
|
|
70
|
+
{ type: 'text', text: ' hello ' },
|
|
71
|
+
{ type: 'text', text: ' world ' },
|
|
72
|
+
],
|
|
73
|
+
};
|
|
74
|
+
expect(extractMessageContent(message)).toBe('hello \n world');
|
|
75
|
+
});
|
|
76
|
+
it('returns empty string for empty array content', () => {
|
|
77
|
+
expect(extractMessageContent({ content: [] })).toBe('');
|
|
78
|
+
});
|
|
79
|
+
it('returns empty string for array with no text parts', () => {
|
|
80
|
+
const message = {
|
|
81
|
+
content: [
|
|
82
|
+
{ type: 'image', url: 'http://example.com' },
|
|
83
|
+
{ type: 'file', name: 'test.txt' },
|
|
84
|
+
],
|
|
85
|
+
};
|
|
86
|
+
expect(extractMessageContent(message)).toBe('');
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
//# sourceMappingURL=message-extraction.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-extraction.test.js","sourceRoot":"","sources":["../../../src/prompt-builder/__tests__/message-extraction.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;QACrC,EAAE,CAAC,sBAAsB,EAAE,GAAG,EAAE;YAC9B,MAAM,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACnE,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,+BAA+B,EAAE,GAAG,EAAE;YACvC,MAAM,C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trigger.test.d.ts","sourceRoot":"","sources":["../../../src/prompt-builder/__tests__/minimal-trigger.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { isMinimalTrigger } from '../minimal-trigger.js';
|
|
3
|
+
describe('minimal-trigger', () => {
|
|
4
|
+
describe('isMinimalTrigger', () => {
|
|
5
|
+
it('returns true for heartbeat trigger', () => {
|
|
6
|
+
expect(isMinimalTrigger('heartbeat')).toBe(true);
|
|
7
|
+
});
|
|
8
|
+
it('returns true for cron trigger', () => {
|
|
9
|
+
expect(isMinimalTrigger('cron')).toBe(true);
|
|
10
|
+
});
|
|
11
|
+
it('returns true for subagent sessionId', () => {
|
|
12
|
+
expect(isMinimalTrigger('user', 'main:subagent:123')).toBe(true);
|
|
13
|
+
});
|
|
14
|
+
it('returns false for user trigger', () => {
|
|
15
|
+
expect(isMinimalTrigger('user')).toBe(false);
|
|
16
|
+
});
|
|
17
|
+
it('returns false for api trigger', () => {
|
|
18
|
+
expect(isMinimalTrigger('api')).toBe(false);
|
|
19
|
+
});
|
|
20
|
+
it('returns false for undefined trigger', () => {
|
|
21
|
+
expect(isMinimalTrigger(undefined)).toBe(false);
|
|
22
|
+
});
|
|
23
|
+
it('returns false for other triggers', () => {
|
|
24
|
+
expect(isMinimalTrigger('manual')).toBe(false);
|
|
25
|
+
expect(isMinimalTrigger('workflow')).toBe(false);
|
|
26
|
+
expect(isMinimalTrigger('test')).toBe(false);
|
|
27
|
+
});
|
|
28
|
+
it('returns false for non-subagent sessionId', () => {
|
|
29
|
+
expect(isMinimalTrigger('user', 'main:agent:123')).toBe(false);
|
|
30
|
+
expect(isMinimalTrigger('user', 'session-123')).toBe(false);
|
|
31
|
+
expect(isMinimalTrigger('user', 'main')).toBe(false);
|
|
32
|
+
});
|
|
33
|
+
it('returns false when sessionId is undefined', () => {
|
|
34
|
+
expect(isMinimalTrigger('user', undefined)).toBe(false);
|
|
35
|
+
});
|
|
36
|
+
it('returns false when sessionId is empty', () => {
|
|
37
|
+
expect(isMinimalTrigger('user', '')).toBe(false);
|
|
38
|
+
});
|
|
39
|
+
it('handles case sensitivity correctly', () => {
|
|
40
|
+
expect(isMinimalTrigger('HEARTBEAT')).toBe(false);
|
|
41
|
+
expect(isMinimalTrigger('Cron')).toBe(false);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=minimal-trigger.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"minimal-trigger.test.js","sourceRoot":"","sources":["../../../src/prompt-builder/__tests__/minimal-trigger.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,EAAE,CAAC,oCAAoC,EAAE,GAAG,EAAE;YAC5C,MAAM,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,+BAA+B,EAAE,GAAG,EAAE;YACvC,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9C,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;YAC7C,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnE,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE;YACxC,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC,C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