@autumnsgrove/groveengine 0.8.0 → 0.8.5
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/components/OnboardingChecklist.svelte +2 -2
- package/dist/components/WispButton.svelte +83 -0
- package/dist/components/WispButton.svelte.d.ts +49 -0
- package/dist/components/WispPanel.svelte +1093 -0
- package/dist/components/WispPanel.svelte.d.ts +49 -0
- package/dist/components/custom/TableOfContents.svelte +12 -1
- package/dist/components/quota/UpgradePrompt.svelte +1 -0
- package/dist/config/wisp.d.ts +145 -0
- package/dist/config/wisp.js +175 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/server/inference-client.d.ts +139 -0
- package/dist/server/inference-client.js +294 -0
- package/dist/ui/components/nature/Logo.svelte +55 -19
- package/dist/ui/components/nature/botanical/LeafFalling.svelte +2 -2
- package/dist/ui/components/nature/botanical/PetalFalling.svelte +7 -7
- package/dist/ui/components/nature/ground/Crocus.svelte +3 -3
- package/dist/ui/components/nature/ground/Daffodil.svelte +3 -3
- package/dist/ui/components/nature/ground/Tulip.svelte +5 -5
- package/dist/ui/components/nature/palette.d.ts +187 -76
- package/dist/ui/components/nature/palette.js +169 -81
- package/dist/ui/components/nature/trees/TreeCherry.svelte +3 -3
- package/dist/ui/components/nature/trees/TreeCherry.svelte.d.ts +1 -1
- package/dist/ui/components/nature/trees/TreePine.svelte +2 -2
- package/dist/ui/components/nature/trees/TreePine.svelte.d.ts +1 -1
- package/dist/ui/components/primitives/textarea/textarea.svelte +1 -1
- package/dist/ui/components/typography/Alagard.svelte +17 -0
- package/dist/ui/components/typography/Alagard.svelte.d.ts +10 -0
- package/dist/ui/components/typography/Atkinson.svelte +17 -0
- package/dist/ui/components/typography/Atkinson.svelte.d.ts +10 -0
- package/dist/ui/components/typography/BodoniModa.svelte +17 -0
- package/dist/ui/components/typography/BodoniModa.svelte.d.ts +10 -0
- package/dist/ui/components/typography/Calistoga.svelte +17 -0
- package/dist/ui/components/typography/Calistoga.svelte.d.ts +10 -0
- package/dist/ui/components/typography/Caveat.svelte +17 -0
- package/dist/ui/components/typography/Caveat.svelte.d.ts +10 -0
- package/dist/ui/components/typography/Cormorant.svelte +17 -0
- package/dist/ui/components/typography/Cormorant.svelte.d.ts +10 -0
- package/dist/ui/components/typography/Cozette.svelte +17 -0
- package/dist/ui/components/typography/Cozette.svelte.d.ts +10 -0
- package/dist/ui/components/typography/EBGaramond.svelte +17 -0
- package/dist/ui/components/typography/EBGaramond.svelte.d.ts +10 -0
- package/dist/ui/components/typography/FontProvider.svelte +98 -0
- package/dist/ui/components/typography/FontProvider.svelte.d.ts +17 -0
- package/dist/ui/components/typography/Fraunces.svelte +17 -0
- package/dist/ui/components/typography/Fraunces.svelte.d.ts +10 -0
- package/dist/ui/components/typography/IBMPlexMono.svelte +17 -0
- package/dist/ui/components/typography/IBMPlexMono.svelte.d.ts +10 -0
- package/dist/ui/components/typography/InstrumentSans.svelte +17 -0
- package/dist/ui/components/typography/InstrumentSans.svelte.d.ts +10 -0
- package/dist/ui/components/typography/Lexend.svelte +17 -0
- package/dist/ui/components/typography/Lexend.svelte.d.ts +10 -0
- package/dist/ui/components/typography/Lora.svelte +17 -0
- package/dist/ui/components/typography/Lora.svelte.d.ts +10 -0
- package/dist/ui/components/typography/Luciole.svelte +17 -0
- package/dist/ui/components/typography/Luciole.svelte.d.ts +10 -0
- package/dist/ui/components/typography/Manrope.svelte +17 -0
- package/dist/ui/components/typography/Manrope.svelte.d.ts +10 -0
- package/dist/ui/components/typography/Merriweather.svelte +17 -0
- package/dist/ui/components/typography/Merriweather.svelte.d.ts +10 -0
- package/dist/ui/components/typography/Nunito.svelte +17 -0
- package/dist/ui/components/typography/Nunito.svelte.d.ts +10 -0
- package/dist/ui/components/typography/OpenDyslexic.svelte +17 -0
- package/dist/ui/components/typography/OpenDyslexic.svelte.d.ts +10 -0
- package/dist/ui/components/typography/PlusJakartaSans.svelte +17 -0
- package/dist/ui/components/typography/PlusJakartaSans.svelte.d.ts +10 -0
- package/dist/ui/components/typography/Quicksand.svelte +17 -0
- package/dist/ui/components/typography/Quicksand.svelte.d.ts +10 -0
- package/dist/ui/components/typography/README.md +153 -0
- package/dist/ui/components/typography/index.d.ts +23 -0
- package/dist/ui/components/typography/index.js +42 -0
- package/dist/ui/components/ui/GlassCarousel.svelte +446 -0
- package/dist/ui/components/ui/GlassCarousel.svelte.d.ts +57 -0
- package/dist/ui/components/ui/GlassConfirmDialog.svelte +2 -1
- package/dist/ui/components/ui/GlassLogo.svelte +2 -1
- package/dist/ui/components/ui/GlassOverlay.svelte +1 -1
- package/dist/ui/components/ui/index.d.ts +1 -0
- package/dist/ui/components/ui/index.js +1 -0
- package/dist/ui/index.d.ts +1 -0
- package/dist/ui/index.js +2 -0
- package/dist/ui/vineyard/index.d.ts +9 -0
- package/dist/ui/vineyard/index.js +8 -0
- package/dist/utils/csrf.js +5 -2
- package/dist/utils/readability.d.ts +89 -0
- package/dist/utils/readability.js +204 -0
- package/package.json +17 -1
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export default WispPanel;
|
|
2
|
+
type WispPanel = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<Props>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const WispPanel: import("svelte").Component<{
|
|
7
|
+
/**
|
|
8
|
+
* - Content to analyze
|
|
9
|
+
*/
|
|
10
|
+
content: string;
|
|
11
|
+
/**
|
|
12
|
+
* - Whether Wisp is enabled
|
|
13
|
+
*/
|
|
14
|
+
enabled: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* - Optional post title for context
|
|
17
|
+
*/
|
|
18
|
+
postTitle: string;
|
|
19
|
+
/**
|
|
20
|
+
* - Optional post slug for logging
|
|
21
|
+
*/
|
|
22
|
+
postSlug: string;
|
|
23
|
+
/**
|
|
24
|
+
* - Callback when user applies a fix
|
|
25
|
+
*/
|
|
26
|
+
onApplyFix: (original: string, suggestion: string) => void;
|
|
27
|
+
}, {}, "">;
|
|
28
|
+
type Props = {
|
|
29
|
+
/**
|
|
30
|
+
* - Content to analyze
|
|
31
|
+
*/
|
|
32
|
+
content: string;
|
|
33
|
+
/**
|
|
34
|
+
* - Whether Wisp is enabled
|
|
35
|
+
*/
|
|
36
|
+
enabled: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* - Optional post title for context
|
|
39
|
+
*/
|
|
40
|
+
postTitle: string;
|
|
41
|
+
/**
|
|
42
|
+
* - Optional post slug for logging
|
|
43
|
+
*/
|
|
44
|
+
postSlug: string;
|
|
45
|
+
/**
|
|
46
|
+
* - Callback when user applies a fix
|
|
47
|
+
*/
|
|
48
|
+
onApplyFix: (original: string, suggestion: string) => void;
|
|
49
|
+
};
|
|
@@ -41,9 +41,20 @@
|
|
|
41
41
|
function scrollToHeader(id) {
|
|
42
42
|
const element = document.getElementById(id);
|
|
43
43
|
if (element) {
|
|
44
|
-
|
|
44
|
+
// Calculate offset for sticky headers
|
|
45
|
+
const offset = 80; // Account for any fixed headers
|
|
46
|
+
const elementPosition = element.getBoundingClientRect().top + window.pageYOffset;
|
|
47
|
+
const offsetPosition = elementPosition - offset;
|
|
48
|
+
|
|
49
|
+
window.scrollTo({
|
|
50
|
+
top: offsetPosition,
|
|
51
|
+
behavior: 'smooth'
|
|
52
|
+
});
|
|
53
|
+
|
|
45
54
|
// Update URL hash without jumping
|
|
46
55
|
history.pushState(null, '', `#${id}`);
|
|
56
|
+
} else {
|
|
57
|
+
console.warn(`TableOfContents: Header element not found for ID: ${id}`);
|
|
47
58
|
}
|
|
48
59
|
}
|
|
49
60
|
</script>
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculate cost for token usage
|
|
3
|
+
* @param {string} model - Model key
|
|
4
|
+
* @param {number} inputTokens - Number of input tokens
|
|
5
|
+
* @param {number} outputTokens - Number of output tokens
|
|
6
|
+
* @returns {number} Cost in USD (rounded to 6 decimal places to avoid floating point errors)
|
|
7
|
+
*/
|
|
8
|
+
export function calculateCost(model: string, inputTokens: number, outputTokens: number): number;
|
|
9
|
+
/**
|
|
10
|
+
* Get the model ID for a provider
|
|
11
|
+
* @param {string} provider - Provider key
|
|
12
|
+
* @param {string} model - Model key
|
|
13
|
+
* @returns {string|null} Full model ID or null if not found
|
|
14
|
+
*/
|
|
15
|
+
export function getModelId(provider: string, model: string): string | null;
|
|
16
|
+
/**
|
|
17
|
+
* Get provider configuration
|
|
18
|
+
* @param {string} provider - Provider key
|
|
19
|
+
* @returns {object|null} Provider config or null
|
|
20
|
+
*/
|
|
21
|
+
export function getProvider(provider: string): object | null;
|
|
22
|
+
/**
|
|
23
|
+
* Get max tokens for an action and mode
|
|
24
|
+
* @param {'grammar'|'tone'|'readability'} action
|
|
25
|
+
* @param {'quick'|'thorough'} mode
|
|
26
|
+
* @returns {number}
|
|
27
|
+
*/
|
|
28
|
+
export function getMaxTokens(action: "grammar" | "tone" | "readability", mode?: "quick" | "thorough"): number;
|
|
29
|
+
export namespace PROVIDERS {
|
|
30
|
+
namespace fireworks {
|
|
31
|
+
let name: string;
|
|
32
|
+
let baseUrl: string;
|
|
33
|
+
let role: string;
|
|
34
|
+
let zdr: boolean;
|
|
35
|
+
let models: {
|
|
36
|
+
'deepseek-v3.2': string;
|
|
37
|
+
'kimi-k2': string;
|
|
38
|
+
'llama-3.1-70b': string;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
namespace cerebras {
|
|
42
|
+
let name_1: string;
|
|
43
|
+
export { name_1 as name };
|
|
44
|
+
let baseUrl_1: string;
|
|
45
|
+
export { baseUrl_1 as baseUrl };
|
|
46
|
+
let role_1: string;
|
|
47
|
+
export { role_1 as role };
|
|
48
|
+
let zdr_1: boolean;
|
|
49
|
+
export { zdr_1 as zdr };
|
|
50
|
+
let models_1: {
|
|
51
|
+
'llama-3.3-70b': string;
|
|
52
|
+
'gpt-oss-120b': string;
|
|
53
|
+
};
|
|
54
|
+
export { models_1 as models };
|
|
55
|
+
}
|
|
56
|
+
namespace groq {
|
|
57
|
+
let name_2: string;
|
|
58
|
+
export { name_2 as name };
|
|
59
|
+
let baseUrl_2: string;
|
|
60
|
+
export { baseUrl_2 as baseUrl };
|
|
61
|
+
let role_2: string;
|
|
62
|
+
export { role_2 as role };
|
|
63
|
+
let zdr_2: boolean;
|
|
64
|
+
export { zdr_2 as zdr };
|
|
65
|
+
let models_2: {
|
|
66
|
+
'llama-3.3-70b': string;
|
|
67
|
+
};
|
|
68
|
+
export { models_2 as models };
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Model fallback cascade
|
|
73
|
+
* Try in order until one succeeds
|
|
74
|
+
*/
|
|
75
|
+
export const MODEL_FALLBACK_CASCADE: {
|
|
76
|
+
provider: string;
|
|
77
|
+
model: string;
|
|
78
|
+
}[];
|
|
79
|
+
export const MODEL_PRICING: {
|
|
80
|
+
'deepseek-v3.2': {
|
|
81
|
+
input: number;
|
|
82
|
+
output: number;
|
|
83
|
+
};
|
|
84
|
+
'kimi-k2': {
|
|
85
|
+
input: number;
|
|
86
|
+
output: number;
|
|
87
|
+
};
|
|
88
|
+
'llama-3.1-70b': {
|
|
89
|
+
input: number;
|
|
90
|
+
output: number;
|
|
91
|
+
};
|
|
92
|
+
'llama-3.3-70b': {
|
|
93
|
+
input: number;
|
|
94
|
+
output: number;
|
|
95
|
+
};
|
|
96
|
+
'gpt-oss-120b': {
|
|
97
|
+
input: number;
|
|
98
|
+
output: number;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
/** Maximum content length for analysis (characters) */
|
|
102
|
+
export const MAX_CONTENT_LENGTH: 50000;
|
|
103
|
+
export namespace MAX_OUTPUT_TOKENS {
|
|
104
|
+
namespace grammar {
|
|
105
|
+
let quick: number;
|
|
106
|
+
let thorough: number;
|
|
107
|
+
}
|
|
108
|
+
namespace tone {
|
|
109
|
+
let quick_1: number;
|
|
110
|
+
export { quick_1 as quick };
|
|
111
|
+
let thorough_1: number;
|
|
112
|
+
export { thorough_1 as thorough };
|
|
113
|
+
}
|
|
114
|
+
let readability: number;
|
|
115
|
+
}
|
|
116
|
+
export namespace RATE_LIMIT {
|
|
117
|
+
let maxRequestsPerHour: number;
|
|
118
|
+
let windowSeconds: number;
|
|
119
|
+
}
|
|
120
|
+
export namespace COST_CAP {
|
|
121
|
+
let enabled: boolean;
|
|
122
|
+
let maxCostUSD: number;
|
|
123
|
+
let warningThreshold: number;
|
|
124
|
+
}
|
|
125
|
+
export namespace PROMPT_MODES {
|
|
126
|
+
export namespace quick_2 {
|
|
127
|
+
let name_3: string;
|
|
128
|
+
export { name_3 as name };
|
|
129
|
+
export let description: string;
|
|
130
|
+
export let temperature: number;
|
|
131
|
+
export let maxOutputMultiplier: number;
|
|
132
|
+
}
|
|
133
|
+
export { quick_2 as quick };
|
|
134
|
+
export namespace thorough_2 {
|
|
135
|
+
let name_4: string;
|
|
136
|
+
export { name_4 as name };
|
|
137
|
+
let description_1: string;
|
|
138
|
+
export { description_1 as description };
|
|
139
|
+
let temperature_1: number;
|
|
140
|
+
export { temperature_1 as temperature };
|
|
141
|
+
let maxOutputMultiplier_1: number;
|
|
142
|
+
export { maxOutputMultiplier_1 as maxOutputMultiplier };
|
|
143
|
+
}
|
|
144
|
+
export { thorough_2 as thorough };
|
|
145
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wisp - Grove Writing Assistant Configuration
|
|
3
|
+
*
|
|
4
|
+
* Model configuration, provider settings, and pricing for the Wisp writing assistant.
|
|
5
|
+
* Uses privacy-first providers with Zero Data Retention (ZDR).
|
|
6
|
+
*
|
|
7
|
+
* @see docs/specs/writing-assistant-unified-spec.md
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// Provider Configuration
|
|
12
|
+
// ============================================================================
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Approved inference providers with ZDR support
|
|
16
|
+
* Order determines fallback priority
|
|
17
|
+
*/
|
|
18
|
+
export const PROVIDERS = {
|
|
19
|
+
fireworks: {
|
|
20
|
+
name: 'Fireworks AI',
|
|
21
|
+
baseUrl: 'https://api.fireworks.ai/inference/v1',
|
|
22
|
+
role: 'primary',
|
|
23
|
+
zdr: true, // Zero Data Retention default for open models
|
|
24
|
+
models: {
|
|
25
|
+
'deepseek-v3.2': 'accounts/fireworks/models/deepseek-v3p2',
|
|
26
|
+
'kimi-k2': 'accounts/fireworks/models/kimi-k2-instruct-0905',
|
|
27
|
+
'llama-3.1-70b': 'accounts/fireworks/models/llama-v3p1-70b-instruct'
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
cerebras: {
|
|
31
|
+
name: 'Cerebras',
|
|
32
|
+
baseUrl: 'https://api.cerebras.ai/v1',
|
|
33
|
+
role: 'backup',
|
|
34
|
+
zdr: true, // US-based, zero retention
|
|
35
|
+
models: {
|
|
36
|
+
'llama-3.3-70b': 'llama-3.3-70b',
|
|
37
|
+
'gpt-oss-120b': 'gpt-oss-120b'
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
groq: {
|
|
41
|
+
name: 'Groq',
|
|
42
|
+
baseUrl: 'https://api.groq.com/openai/v1',
|
|
43
|
+
role: 'tertiary',
|
|
44
|
+
zdr: true, // Explicit ZDR toggle
|
|
45
|
+
models: {
|
|
46
|
+
'llama-3.3-70b': 'llama-3.3-70b-versatile'
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Model fallback cascade
|
|
53
|
+
* Try in order until one succeeds
|
|
54
|
+
*/
|
|
55
|
+
export const MODEL_FALLBACK_CASCADE = [
|
|
56
|
+
{ provider: 'fireworks', model: 'deepseek-v3.2' },
|
|
57
|
+
{ provider: 'fireworks', model: 'kimi-k2' },
|
|
58
|
+
{ provider: 'fireworks', model: 'llama-3.1-70b' },
|
|
59
|
+
{ provider: 'cerebras', model: 'llama-3.3-70b' },
|
|
60
|
+
{ provider: 'groq', model: 'llama-3.3-70b' }
|
|
61
|
+
];
|
|
62
|
+
|
|
63
|
+
// ============================================================================
|
|
64
|
+
// Pricing (per million tokens)
|
|
65
|
+
// ============================================================================
|
|
66
|
+
|
|
67
|
+
export const MODEL_PRICING = {
|
|
68
|
+
'deepseek-v3.2': { input: 0.56, output: 1.68 },
|
|
69
|
+
'kimi-k2': { input: 0.60, output: 2.50 },
|
|
70
|
+
'llama-3.1-70b': { input: 0.90, output: 0.90 },
|
|
71
|
+
'llama-3.3-70b': { input: 0.59, output: 0.79 },
|
|
72
|
+
'gpt-oss-120b': { input: 0.25, output: 0.69 }
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
// ============================================================================
|
|
76
|
+
// Limits & Thresholds
|
|
77
|
+
// ============================================================================
|
|
78
|
+
|
|
79
|
+
/** Maximum content length for analysis (characters) */
|
|
80
|
+
export const MAX_CONTENT_LENGTH = 50000;
|
|
81
|
+
|
|
82
|
+
/** Max output tokens by analysis type and mode */
|
|
83
|
+
export const MAX_OUTPUT_TOKENS = {
|
|
84
|
+
grammar: { quick: 1024, thorough: 2048 },
|
|
85
|
+
tone: { quick: 512, thorough: 1024 },
|
|
86
|
+
readability: 0 // No AI call needed
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Rate limiting (burst protection)
|
|
91
|
+
* Note: Cost cap is the true monthly limit (~1000 requests at current pricing).
|
|
92
|
+
* Hourly limit prevents abuse bursts, not total monthly usage.
|
|
93
|
+
*/
|
|
94
|
+
export const RATE_LIMIT = {
|
|
95
|
+
maxRequestsPerHour: 10,
|
|
96
|
+
windowSeconds: 3600
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/** Monthly cost cap per user (the true usage limit) */
|
|
100
|
+
export const COST_CAP = {
|
|
101
|
+
enabled: true,
|
|
102
|
+
maxCostUSD: 5.0,
|
|
103
|
+
warningThreshold: 0.8 // Warn at 80%
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
// ============================================================================
|
|
107
|
+
// Prompt Modes
|
|
108
|
+
// ============================================================================
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Prompt modes control analysis depth without changing models
|
|
112
|
+
*/
|
|
113
|
+
export const PROMPT_MODES = {
|
|
114
|
+
quick: {
|
|
115
|
+
name: 'Quick',
|
|
116
|
+
description: 'Fast essential checks',
|
|
117
|
+
temperature: 0.1,
|
|
118
|
+
maxOutputMultiplier: 1
|
|
119
|
+
},
|
|
120
|
+
thorough: {
|
|
121
|
+
name: 'Thorough',
|
|
122
|
+
description: 'Comprehensive analysis',
|
|
123
|
+
temperature: 0.2,
|
|
124
|
+
maxOutputMultiplier: 2
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
// ============================================================================
|
|
129
|
+
// Helper Functions
|
|
130
|
+
// ============================================================================
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Calculate cost for token usage
|
|
134
|
+
* @param {string} model - Model key
|
|
135
|
+
* @param {number} inputTokens - Number of input tokens
|
|
136
|
+
* @param {number} outputTokens - Number of output tokens
|
|
137
|
+
* @returns {number} Cost in USD (rounded to 6 decimal places to avoid floating point errors)
|
|
138
|
+
*/
|
|
139
|
+
export function calculateCost(model, inputTokens, outputTokens) {
|
|
140
|
+
const pricing = MODEL_PRICING[model] || MODEL_PRICING['deepseek-v3.2'];
|
|
141
|
+
const cost = (inputTokens * pricing.input + outputTokens * pricing.output) / 1_000_000;
|
|
142
|
+
// Round to 6 decimal places to avoid floating point precision issues
|
|
143
|
+
return Math.round(cost * 1_000_000) / 1_000_000;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Get the model ID for a provider
|
|
148
|
+
* @param {string} provider - Provider key
|
|
149
|
+
* @param {string} model - Model key
|
|
150
|
+
* @returns {string|null} Full model ID or null if not found
|
|
151
|
+
*/
|
|
152
|
+
export function getModelId(provider, model) {
|
|
153
|
+
return PROVIDERS[provider]?.models[model] || null;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Get provider configuration
|
|
158
|
+
* @param {string} provider - Provider key
|
|
159
|
+
* @returns {object|null} Provider config or null
|
|
160
|
+
*/
|
|
161
|
+
export function getProvider(provider) {
|
|
162
|
+
return PROVIDERS[provider] || null;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Get max tokens for an action and mode
|
|
167
|
+
* @param {'grammar'|'tone'|'readability'} action
|
|
168
|
+
* @param {'quick'|'thorough'} mode
|
|
169
|
+
* @returns {number}
|
|
170
|
+
*/
|
|
171
|
+
export function getMaxTokens(action, mode = 'quick') {
|
|
172
|
+
const tokens = MAX_OUTPUT_TOKENS[action];
|
|
173
|
+
if (typeof tokens === 'number') return tokens;
|
|
174
|
+
return tokens?.[mode] || 1024;
|
|
175
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ export { default as MobileTOC } from './components/custom/MobileTOC.svelte';
|
|
|
6
6
|
export { default as CollapsibleSection } from './components/custom/CollapsibleSection.svelte';
|
|
7
7
|
export { default as MarkdownEditor } from './components/admin/MarkdownEditor.svelte';
|
|
8
8
|
export { default as GutterManager } from './components/admin/GutterManager.svelte';
|
|
9
|
+
export { default as WispPanel } from './components/WispPanel.svelte';
|
|
10
|
+
export { default as WispButton } from './components/WispButton.svelte';
|
|
9
11
|
export { QuotaWidget, QuotaWarning, UpgradePrompt } from './components/quota/index';
|
|
10
12
|
export { default as ImageGallery } from './ui/components/gallery/ImageGallery.svelte';
|
|
11
13
|
export { default as Lightbox } from './ui/components/gallery/Lightbox.svelte';
|
package/dist/index.js
CHANGED
|
@@ -9,6 +9,9 @@ export { default as CollapsibleSection } from './components/custom/CollapsibleSe
|
|
|
9
9
|
// Admin components
|
|
10
10
|
export { default as MarkdownEditor } from './components/admin/MarkdownEditor.svelte';
|
|
11
11
|
export { default as GutterManager } from './components/admin/GutterManager.svelte';
|
|
12
|
+
// Wisp - Writing Assistant
|
|
13
|
+
export { default as WispPanel } from './components/WispPanel.svelte';
|
|
14
|
+
export { default as WispButton } from './components/WispButton.svelte';
|
|
12
15
|
// Quota components
|
|
13
16
|
export { QuotaWidget, QuotaWarning, UpgradePrompt } from './components/quota/index';
|
|
14
17
|
// Gallery components (from UI module)
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Call an inference API with automatic fallback
|
|
3
|
+
*
|
|
4
|
+
* @param {InferenceRequest} request - The inference request
|
|
5
|
+
* @param {Object} secrets - API keys object
|
|
6
|
+
* @param {string} [secrets.FIREWORKS_API_KEY] - Fireworks AI key
|
|
7
|
+
* @param {string} [secrets.CEREBRAS_API_KEY] - Cerebras key
|
|
8
|
+
* @param {string} [secrets.GROQ_API_KEY] - Groq key
|
|
9
|
+
* @returns {Promise<InferenceResponse>}
|
|
10
|
+
* @throws {InferenceClientError}
|
|
11
|
+
*/
|
|
12
|
+
export function callInference(request: InferenceRequest, secrets: {
|
|
13
|
+
FIREWORKS_API_KEY?: string | undefined;
|
|
14
|
+
CEREBRAS_API_KEY?: string | undefined;
|
|
15
|
+
GROQ_API_KEY?: string | undefined;
|
|
16
|
+
}): Promise<InferenceResponse>;
|
|
17
|
+
/**
|
|
18
|
+
* Wrap user content with security markers to prevent prompt injection
|
|
19
|
+
*
|
|
20
|
+
* @param {string} content - User content to analyze
|
|
21
|
+
* @param {string} taskDescription - Description of the analysis task
|
|
22
|
+
* @returns {string} Secured prompt with content
|
|
23
|
+
*/
|
|
24
|
+
export function secureUserContent(content: string, taskDescription: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Smart truncation for long content
|
|
27
|
+
* Captures beginning, end, and samples from middle
|
|
28
|
+
*
|
|
29
|
+
* @param {string} content - Content to truncate
|
|
30
|
+
* @param {number} [maxChars=20000] - Maximum characters
|
|
31
|
+
* @returns {string} Truncated content
|
|
32
|
+
*/
|
|
33
|
+
export function smartTruncate(content: string, maxChars?: number): string;
|
|
34
|
+
/**
|
|
35
|
+
* @typedef {Object} InferenceRequest
|
|
36
|
+
* @property {string} prompt - The prompt to send
|
|
37
|
+
* @property {'quick'|'thorough'} [mode='quick'] - Analysis mode
|
|
38
|
+
* @property {number} [maxTokens=1024] - Max output tokens
|
|
39
|
+
* @property {number} [temperature=0.1] - Temperature for generation
|
|
40
|
+
* @property {string} [preferredProvider] - Preferred provider (optional)
|
|
41
|
+
* @property {string} [preferredModel] - Preferred model (optional)
|
|
42
|
+
*/
|
|
43
|
+
/**
|
|
44
|
+
* @typedef {Object} InferenceResponse
|
|
45
|
+
* @property {string} content - The generated content
|
|
46
|
+
* @property {Object} usage - Token usage
|
|
47
|
+
* @property {number} usage.input - Input tokens
|
|
48
|
+
* @property {number} usage.output - Output tokens
|
|
49
|
+
* @property {string} model - Model used
|
|
50
|
+
* @property {string} provider - Provider used
|
|
51
|
+
*/
|
|
52
|
+
/**
|
|
53
|
+
* @typedef {Object} InferenceError
|
|
54
|
+
* @property {string} code - Error code
|
|
55
|
+
* @property {string} message - Error message
|
|
56
|
+
* @property {string} [provider] - Provider that failed
|
|
57
|
+
*/
|
|
58
|
+
export class InferenceClientError extends Error {
|
|
59
|
+
/**
|
|
60
|
+
* @param {string} message
|
|
61
|
+
* @param {string} code
|
|
62
|
+
* @param {string} [provider]
|
|
63
|
+
* @param {unknown} [cause]
|
|
64
|
+
*/
|
|
65
|
+
constructor(message: string, code: string, provider?: string, cause?: unknown);
|
|
66
|
+
code: string;
|
|
67
|
+
provider: string | undefined;
|
|
68
|
+
cause: unknown;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Strip markdown formatting for cleaner analysis
|
|
72
|
+
* Re-exported from readability.js for consistency
|
|
73
|
+
*
|
|
74
|
+
* @param {string} content - Markdown content
|
|
75
|
+
* @returns {string} Plain text content
|
|
76
|
+
*/
|
|
77
|
+
export const stripMarkdown: typeof stripMarkdownForAnalysis;
|
|
78
|
+
export type InferenceRequest = {
|
|
79
|
+
/**
|
|
80
|
+
* - The prompt to send
|
|
81
|
+
*/
|
|
82
|
+
prompt: string;
|
|
83
|
+
/**
|
|
84
|
+
* - Analysis mode
|
|
85
|
+
*/
|
|
86
|
+
mode?: "quick" | "thorough" | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* - Max output tokens
|
|
89
|
+
*/
|
|
90
|
+
maxTokens?: number | undefined;
|
|
91
|
+
/**
|
|
92
|
+
* - Temperature for generation
|
|
93
|
+
*/
|
|
94
|
+
temperature?: number | undefined;
|
|
95
|
+
/**
|
|
96
|
+
* - Preferred provider (optional)
|
|
97
|
+
*/
|
|
98
|
+
preferredProvider?: string | undefined;
|
|
99
|
+
/**
|
|
100
|
+
* - Preferred model (optional)
|
|
101
|
+
*/
|
|
102
|
+
preferredModel?: string | undefined;
|
|
103
|
+
};
|
|
104
|
+
export type InferenceResponse = {
|
|
105
|
+
/**
|
|
106
|
+
* - The generated content
|
|
107
|
+
*/
|
|
108
|
+
content: string;
|
|
109
|
+
/**
|
|
110
|
+
* - Token usage
|
|
111
|
+
*/
|
|
112
|
+
usage: {
|
|
113
|
+
input: number;
|
|
114
|
+
output: number;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* - Model used
|
|
118
|
+
*/
|
|
119
|
+
model: string;
|
|
120
|
+
/**
|
|
121
|
+
* - Provider used
|
|
122
|
+
*/
|
|
123
|
+
provider: string;
|
|
124
|
+
};
|
|
125
|
+
export type InferenceError = {
|
|
126
|
+
/**
|
|
127
|
+
* - Error code
|
|
128
|
+
*/
|
|
129
|
+
code: string;
|
|
130
|
+
/**
|
|
131
|
+
* - Error message
|
|
132
|
+
*/
|
|
133
|
+
message: string;
|
|
134
|
+
/**
|
|
135
|
+
* - Provider that failed
|
|
136
|
+
*/
|
|
137
|
+
provider?: string | undefined;
|
|
138
|
+
};
|
|
139
|
+
import { stripMarkdownForAnalysis } from '../utils/readability.js';
|