@frankieai/core 0.2.6 → 0.2.7

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.d.cts CHANGED
@@ -309,6 +309,8 @@ declare const personaProfileSchema: z.ZodObject<{
309
309
  publishableKey: z.ZodString;
310
310
  pagePatterns: z.ZodDefault<z.ZodArray<z.ZodString>>;
311
311
  allowAnonymous: z.ZodOptional<z.ZodBoolean>;
312
+ scope: z.ZodOptional<z.ZodString>;
313
+ contactUrl: z.ZodOptional<z.ZodString>;
312
314
  branding: z.ZodOptional<z.ZodObject<{
313
315
  name: z.ZodOptional<z.ZodString>;
314
316
  tagline: z.ZodOptional<z.ZodString>;
@@ -583,6 +585,8 @@ declare const frankieConfigSchema: z.ZodObject<{
583
585
  publishableKey: z.ZodString;
584
586
  pagePatterns: z.ZodDefault<z.ZodArray<z.ZodString>>;
585
587
  allowAnonymous: z.ZodOptional<z.ZodBoolean>;
588
+ scope: z.ZodOptional<z.ZodString>;
589
+ contactUrl: z.ZodOptional<z.ZodString>;
586
590
  branding: z.ZodOptional<z.ZodObject<{
587
591
  name: z.ZodOptional<z.ZodString>;
588
592
  tagline: z.ZodOptional<z.ZodString>;
@@ -681,6 +685,13 @@ declare function defineFrankieConfig(config: FrankieConfigInput): FrankieConfigI
681
685
  * key returns null.
682
686
  */
683
687
  declare function resolvePersonaConfig(config: FrankieConfig, publishableKey: string): FrankieConfig | null;
688
+ /**
689
+ * A persona's instructions as the agent runs them: its role instructions,
690
+ * then what it helps with and the boundary that follows from it. Off-topic
691
+ * questions get a short "not here" (and a hand-off when the agent escalates)
692
+ * rather than a guess.
693
+ */
694
+ declare function personaInstructions(persona: PersonaProfile): string;
684
695
  /**
685
696
  * Whether a Next.js `usePathname()` value matches an App-Router path glob:
686
697
  * `**` matches any depth (including `/`), `*` matches within one segment, and a
@@ -1212,4 +1223,4 @@ declare function normalizeColor(raw: string): string | undefined;
1212
1223
  */
1213
1224
  declare function inferTheme(files: Record<string, string>, root?: string): InferredTheme | undefined;
1214
1225
 
1215
- export { type AgentConfig, type ApiCapability, type ApiDocument, type ApiSourceConfig, type ApiToolInventory, type AuthConfig, type AuthStrategy, type BrandingConfig, type ChatAttachment, type ChatRequestBody, type CreateSessionBody, type CreateSessionResponse, FIREWORKS_MODELS, type FeaturesConfig, type FrankieConfig, type FrankieConfigInput, type FrankieErrorCode, type FrankieServerEvent, type HostToolRequest, type HostToolResult, type InferredTheme, type InstallPlan, type InstallProject, type KnowledgeBaseConfig, type LimitsConfig, type LoadedSkill, type McpServerConfig, type ModelChoice, type ModelConfig, type PersonaProfile, type PublicFeatures, type PublicWidgetConfig, SKILL_TOOL_NAME, STANDARD_AGENT_IDS, STARTER_PROMPT_ICONS, type StarterPrompt, type StarterPromptIcon, type StopReason, type ThinkingLevel, type ToolDecision, type ToolPolicy, type ToolResultBody, type UsageSummary, type WidgetTheme, type WidgetThemeConfig, type WorkspaceSkill, activeSkills, agentConfigSchema, apiCapabilitySchema, apiMethods, apiOperations, apiSourceSchema, approvedSkillTools, assertNoCommittedFrankieKeys, authConfigSchema, brandingConfigSchema, canonicalJson, compareApiDocuments, defineFrankieConfig, describeTool, draftSkill, evaluateToolPolicy, featuresConfigSchema, frankieConfigSchema, inferTheme, insertImport, installAgentIds, installBranch, installTitle, knowledgeBaseSchema, knowledgeSourceSchema, limitsConfigSchema, matchPath, matchesAnyPagePattern, matchesInstallBranch, matchesPagePattern, mcpServerSchema, modelChoiceSchema, modelConfigSchema, moduleImporter, mountWidget, normalizeColor, operationId, parseFrankieConfig, personaEnvKey, personaProfileSchema, plainText, planHostedInstall, renderJson, resolvePersonaConfig, sdkUpdateWorkflow, skillSchema, starterPromptSchema, suggestedPromptsFromSkills, thinkingLevelSchema, toolDescriptions, toolPolicySchema, validateApiDocument, widgetThemeSchema, withDependencies };
1226
+ export { type AgentConfig, type ApiCapability, type ApiDocument, type ApiSourceConfig, type ApiToolInventory, type AuthConfig, type AuthStrategy, type BrandingConfig, type ChatAttachment, type ChatRequestBody, type CreateSessionBody, type CreateSessionResponse, FIREWORKS_MODELS, type FeaturesConfig, type FrankieConfig, type FrankieConfigInput, type FrankieErrorCode, type FrankieServerEvent, type HostToolRequest, type HostToolResult, type InferredTheme, type InstallPlan, type InstallProject, type KnowledgeBaseConfig, type LimitsConfig, type LoadedSkill, type McpServerConfig, type ModelChoice, type ModelConfig, type PersonaProfile, type PublicFeatures, type PublicWidgetConfig, SKILL_TOOL_NAME, STANDARD_AGENT_IDS, STARTER_PROMPT_ICONS, type StarterPrompt, type StarterPromptIcon, type StopReason, type ThinkingLevel, type ToolDecision, type ToolPolicy, type ToolResultBody, type UsageSummary, type WidgetTheme, type WidgetThemeConfig, type WorkspaceSkill, activeSkills, agentConfigSchema, apiCapabilitySchema, apiMethods, apiOperations, apiSourceSchema, approvedSkillTools, assertNoCommittedFrankieKeys, authConfigSchema, brandingConfigSchema, canonicalJson, compareApiDocuments, defineFrankieConfig, describeTool, draftSkill, evaluateToolPolicy, featuresConfigSchema, frankieConfigSchema, inferTheme, insertImport, installAgentIds, installBranch, installTitle, knowledgeBaseSchema, knowledgeSourceSchema, limitsConfigSchema, matchPath, matchesAnyPagePattern, matchesInstallBranch, matchesPagePattern, mcpServerSchema, modelChoiceSchema, modelConfigSchema, moduleImporter, mountWidget, normalizeColor, operationId, parseFrankieConfig, personaEnvKey, personaInstructions, personaProfileSchema, plainText, planHostedInstall, renderJson, resolvePersonaConfig, sdkUpdateWorkflow, skillSchema, starterPromptSchema, suggestedPromptsFromSkills, thinkingLevelSchema, toolDescriptions, toolPolicySchema, validateApiDocument, widgetThemeSchema, withDependencies };
package/dist/index.d.ts CHANGED
@@ -309,6 +309,8 @@ declare const personaProfileSchema: z.ZodObject<{
309
309
  publishableKey: z.ZodString;
310
310
  pagePatterns: z.ZodDefault<z.ZodArray<z.ZodString>>;
311
311
  allowAnonymous: z.ZodOptional<z.ZodBoolean>;
312
+ scope: z.ZodOptional<z.ZodString>;
313
+ contactUrl: z.ZodOptional<z.ZodString>;
312
314
  branding: z.ZodOptional<z.ZodObject<{
313
315
  name: z.ZodOptional<z.ZodString>;
314
316
  tagline: z.ZodOptional<z.ZodString>;
@@ -583,6 +585,8 @@ declare const frankieConfigSchema: z.ZodObject<{
583
585
  publishableKey: z.ZodString;
584
586
  pagePatterns: z.ZodDefault<z.ZodArray<z.ZodString>>;
585
587
  allowAnonymous: z.ZodOptional<z.ZodBoolean>;
588
+ scope: z.ZodOptional<z.ZodString>;
589
+ contactUrl: z.ZodOptional<z.ZodString>;
586
590
  branding: z.ZodOptional<z.ZodObject<{
587
591
  name: z.ZodOptional<z.ZodString>;
588
592
  tagline: z.ZodOptional<z.ZodString>;
@@ -681,6 +685,13 @@ declare function defineFrankieConfig(config: FrankieConfigInput): FrankieConfigI
681
685
  * key returns null.
682
686
  */
683
687
  declare function resolvePersonaConfig(config: FrankieConfig, publishableKey: string): FrankieConfig | null;
688
+ /**
689
+ * A persona's instructions as the agent runs them: its role instructions,
690
+ * then what it helps with and the boundary that follows from it. Off-topic
691
+ * questions get a short "not here" (and a hand-off when the agent escalates)
692
+ * rather than a guess.
693
+ */
694
+ declare function personaInstructions(persona: PersonaProfile): string;
684
695
  /**
685
696
  * Whether a Next.js `usePathname()` value matches an App-Router path glob:
686
697
  * `**` matches any depth (including `/`), `*` matches within one segment, and a
@@ -1212,4 +1223,4 @@ declare function normalizeColor(raw: string): string | undefined;
1212
1223
  */
1213
1224
  declare function inferTheme(files: Record<string, string>, root?: string): InferredTheme | undefined;
1214
1225
 
1215
- export { type AgentConfig, type ApiCapability, type ApiDocument, type ApiSourceConfig, type ApiToolInventory, type AuthConfig, type AuthStrategy, type BrandingConfig, type ChatAttachment, type ChatRequestBody, type CreateSessionBody, type CreateSessionResponse, FIREWORKS_MODELS, type FeaturesConfig, type FrankieConfig, type FrankieConfigInput, type FrankieErrorCode, type FrankieServerEvent, type HostToolRequest, type HostToolResult, type InferredTheme, type InstallPlan, type InstallProject, type KnowledgeBaseConfig, type LimitsConfig, type LoadedSkill, type McpServerConfig, type ModelChoice, type ModelConfig, type PersonaProfile, type PublicFeatures, type PublicWidgetConfig, SKILL_TOOL_NAME, STANDARD_AGENT_IDS, STARTER_PROMPT_ICONS, type StarterPrompt, type StarterPromptIcon, type StopReason, type ThinkingLevel, type ToolDecision, type ToolPolicy, type ToolResultBody, type UsageSummary, type WidgetTheme, type WidgetThemeConfig, type WorkspaceSkill, activeSkills, agentConfigSchema, apiCapabilitySchema, apiMethods, apiOperations, apiSourceSchema, approvedSkillTools, assertNoCommittedFrankieKeys, authConfigSchema, brandingConfigSchema, canonicalJson, compareApiDocuments, defineFrankieConfig, describeTool, draftSkill, evaluateToolPolicy, featuresConfigSchema, frankieConfigSchema, inferTheme, insertImport, installAgentIds, installBranch, installTitle, knowledgeBaseSchema, knowledgeSourceSchema, limitsConfigSchema, matchPath, matchesAnyPagePattern, matchesInstallBranch, matchesPagePattern, mcpServerSchema, modelChoiceSchema, modelConfigSchema, moduleImporter, mountWidget, normalizeColor, operationId, parseFrankieConfig, personaEnvKey, personaProfileSchema, plainText, planHostedInstall, renderJson, resolvePersonaConfig, sdkUpdateWorkflow, skillSchema, starterPromptSchema, suggestedPromptsFromSkills, thinkingLevelSchema, toolDescriptions, toolPolicySchema, validateApiDocument, widgetThemeSchema, withDependencies };
1226
+ export { type AgentConfig, type ApiCapability, type ApiDocument, type ApiSourceConfig, type ApiToolInventory, type AuthConfig, type AuthStrategy, type BrandingConfig, type ChatAttachment, type ChatRequestBody, type CreateSessionBody, type CreateSessionResponse, FIREWORKS_MODELS, type FeaturesConfig, type FrankieConfig, type FrankieConfigInput, type FrankieErrorCode, type FrankieServerEvent, type HostToolRequest, type HostToolResult, type InferredTheme, type InstallPlan, type InstallProject, type KnowledgeBaseConfig, type LimitsConfig, type LoadedSkill, type McpServerConfig, type ModelChoice, type ModelConfig, type PersonaProfile, type PublicFeatures, type PublicWidgetConfig, SKILL_TOOL_NAME, STANDARD_AGENT_IDS, STARTER_PROMPT_ICONS, type StarterPrompt, type StarterPromptIcon, type StopReason, type ThinkingLevel, type ToolDecision, type ToolPolicy, type ToolResultBody, type UsageSummary, type WidgetTheme, type WidgetThemeConfig, type WorkspaceSkill, activeSkills, agentConfigSchema, apiCapabilitySchema, apiMethods, apiOperations, apiSourceSchema, approvedSkillTools, assertNoCommittedFrankieKeys, authConfigSchema, brandingConfigSchema, canonicalJson, compareApiDocuments, defineFrankieConfig, describeTool, draftSkill, evaluateToolPolicy, featuresConfigSchema, frankieConfigSchema, inferTheme, insertImport, installAgentIds, installBranch, installTitle, knowledgeBaseSchema, knowledgeSourceSchema, limitsConfigSchema, matchPath, matchesAnyPagePattern, matchesInstallBranch, matchesPagePattern, mcpServerSchema, modelChoiceSchema, modelConfigSchema, moduleImporter, mountWidget, normalizeColor, operationId, parseFrankieConfig, personaEnvKey, personaInstructions, personaProfileSchema, plainText, planHostedInstall, renderJson, resolvePersonaConfig, sdkUpdateWorkflow, skillSchema, starterPromptSchema, suggestedPromptsFromSkills, thinkingLevelSchema, toolDescriptions, toolPolicySchema, validateApiDocument, widgetThemeSchema, withDependencies };
package/dist/index.js CHANGED
@@ -529,6 +529,18 @@ var personaProfileSchema = z2.object({
529
529
  * sign in.
530
530
  */
531
531
  allowAnonymous: z2.boolean().optional(),
532
+ /**
533
+ * What this agent helps with, in the team's own words ("pricing, plans,
534
+ * getting started"). The one thing a team needs to write; the agent's role,
535
+ * greeting and instructions come from defaults. It is added to the agent's
536
+ * instructions at runtime (see `personaInstructions`).
537
+ */
538
+ scope: z2.string().trim().max(2e3).optional(),
539
+ /**
540
+ * Where to send people when the agent can't answer and it doesn't hand the
541
+ * chat to the team itself: a contact page (https) or an email (mailto:).
542
+ */
543
+ contactUrl: z2.string().trim().max(500).regex(/^(?:https:\/\/[^\s]+|mailto:[^\s@]+@[^\s@]+)$/, "Use an https:// link or a mailto: address.").optional(),
532
544
  /**
533
545
  * Shallow-merged over the workspace branding. Each field is optional with no
534
546
  * default, so only the keys the persona sets override the workspace's — an
@@ -595,11 +607,20 @@ function resolvePersonaConfig(config, publishableKey) {
595
607
  branding: { ...config.branding, ...persona.branding ?? {} },
596
608
  auth: { ...config.auth, publishableKey: persona.publishableKey, allowAnonymous: persona.allowAnonymous ?? config.auth.allowAnonymous },
597
609
  pagePatterns: persona.pagePatterns,
598
- agent: persona.agent,
610
+ agent: { ...persona.agent, systemPrompt: personaInstructions(persona) },
599
611
  features: persona.features,
600
612
  knowledgeBase: persona.knowledgeBase
601
613
  });
602
614
  }
615
+ function personaInstructions(persona) {
616
+ const base = persona.agent.systemPrompt.trim();
617
+ const scope = persona.scope?.trim();
618
+ const handsOff = persona.features.escalation.enabled;
619
+ const contact = !handsOff ? persona.contactUrl?.trim() : void 0;
620
+ const fallback = handsOff ? "" : contact ? `When you can't answer from what you know, or someone asks for a person, say so briefly and point them to ${contact} to reach the team. Never guess.` : "When you can't answer from what you know, say so plainly. Never guess, and never promise that someone will follow up.";
621
+ const boundary = "Stay within this. If someone asks about something outside it, say briefly that it isn't something you can help with here" + (handsOff ? ", and offer to connect them with the team." : contact ? ", and share the contact link." : ".");
622
+ return [base, scope ? "What you help with, in the team's own words:\n" + scope + "\n\n" + boundary : "", fallback].filter(Boolean).join("\n\n");
623
+ }
603
624
  function normalizeRoutePath(value) {
604
625
  let path = (value || "/").split(/[?#]/)[0].trim();
605
626
  if (!path.startsWith("/")) path = "/" + path;
@@ -1519,6 +1540,7 @@ function oklchToHex(l, c, hDeg) {
1519
1540
  var NUMBER = String.raw`-?\d*\.?\d+`;
1520
1541
  var parts = (body) => body.replace(/\/.*$/, "").split(/[\s,]+/).filter(Boolean);
1521
1542
  function normalizeColor(raw) {
1543
+ if (raw.length > 200) return void 0;
1522
1544
  const value = raw.trim().replace(/\s*!important$/, "").toLowerCase();
1523
1545
  let match = value.match(/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/);
1524
1546
  if (match) {
@@ -1545,20 +1567,58 @@ function normalizeColor(raw) {
1545
1567
  }
1546
1568
  return void 0;
1547
1569
  }
1570
+ function cssBlocks(source) {
1571
+ const blocks = [];
1572
+ let segmentStart = 0;
1573
+ for (let at = 0; at < source.length; ) {
1574
+ const open = source.indexOf("{", at);
1575
+ if (open === -1) break;
1576
+ const nextOpen = source.indexOf("{", open + 1);
1577
+ const close = source.indexOf("}", open + 1);
1578
+ if (close === -1) break;
1579
+ if (nextOpen !== -1 && nextOpen < close) {
1580
+ segmentStart = open + 1;
1581
+ at = open + 1;
1582
+ continue;
1583
+ }
1584
+ blocks.push([source.slice(segmentStart, open), source.slice(open + 1, close)]);
1585
+ segmentStart = close + 1;
1586
+ at = close + 1;
1587
+ }
1588
+ return blocks;
1589
+ }
1590
+ function customProperty(declaration) {
1591
+ const colon = declaration.indexOf(":");
1592
+ if (colon === -1) return void 0;
1593
+ const name = declaration.slice(0, colon).trim();
1594
+ const value = declaration.slice(colon + 1).trim();
1595
+ return name.length <= 100 && value.length <= 200 && /^--[\w-]+$/.test(name) && value ? [name, value] : void 0;
1596
+ }
1548
1597
  function rootVariables(css) {
1549
1598
  const vars = /* @__PURE__ */ new Map();
1550
- const source = css.replace(/\/\*[\s\S]*?\*\//g, "");
1551
- const blocks = /([^{}]*)\{([^{}]*)\}/g;
1552
- for (let block = blocks.exec(source); block; block = blocks.exec(source)) {
1553
- const selector = block[1].split(";").pop().trim();
1599
+ const source = stripComments(css);
1600
+ for (const [rawSelector, body] of cssBlocks(source)) {
1601
+ const selector = rawSelector.split(";").pop().trim();
1602
+ if (selector.length > 1e3) continue;
1554
1603
  if (!/(?:^|[\s,]):root\b(?![^,]*\.dark)|^@theme\b/.test(selector) || /\.dark|\[data-theme/.test(selector)) continue;
1555
- for (const declaration of block[2].split(";")) {
1556
- const found = declaration.match(/^\s*(--[\w-]+)\s*:\s*([\s\S]+?)\s*$/);
1557
- if (found && !vars.has(found[1])) vars.set(found[1], found[2]);
1604
+ for (const declaration of body.split(";")) {
1605
+ const found = customProperty(declaration);
1606
+ if (found && !vars.has(found[0])) vars.set(found[0], found[1]);
1558
1607
  }
1559
1608
  }
1560
1609
  return vars;
1561
1610
  }
1611
+ function stripComments(css) {
1612
+ let out = "";
1613
+ for (let at = 0; ; ) {
1614
+ const start = css.indexOf("/*", at);
1615
+ if (start === -1) return out + css.slice(at);
1616
+ out += css.slice(at, start);
1617
+ const end = css.indexOf("*/", start + 2);
1618
+ if (end === -1) return out;
1619
+ at = end + 2;
1620
+ }
1621
+ }
1562
1622
  function resolve(value, vars, depth = 0) {
1563
1623
  if (depth > 4) return void 0;
1564
1624
  const reference = value.match(/^(?:(hsla?|oklch|rgba?)\(\s*)?var\(\s*(--[\w-]+)\s*(?:,[^)]*)?\)\s*\)?$/i);
@@ -1670,6 +1730,7 @@ export {
1670
1730
  operationId,
1671
1731
  parseFrankieConfig,
1672
1732
  personaEnvKey,
1733
+ personaInstructions,
1673
1734
  personaProfileSchema,
1674
1735
  plainText,
1675
1736
  planHostedInstall,