lua-cli 3.1.0 → 3.2.0-alpha.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.
Files changed (53) hide show
  1. package/README.md +2 -5
  2. package/dist/api/marketplace.api.service.d.ts +4 -2
  3. package/dist/api/marketplace.api.service.js +6 -0
  4. package/dist/api/persona.api.service.d.ts +54 -0
  5. package/dist/api/persona.api.service.js +89 -0
  6. package/dist/api-exports.d.ts +19 -0
  7. package/dist/api-exports.js +21 -0
  8. package/dist/cli/command-definitions.js +29 -1
  9. package/dist/commands/chat.js +2 -3
  10. package/dist/commands/chatClear.d.ts +5 -1
  11. package/dist/commands/chatClear.js +19 -8
  12. package/dist/commands/compile.d.ts +4 -1
  13. package/dist/commands/compile.js +27 -4
  14. package/dist/commands/index.d.ts +1 -0
  15. package/dist/commands/index.js +1 -0
  16. package/dist/commands/init.js +4 -4
  17. package/dist/commands/marketplace.js +87 -42
  18. package/dist/commands/persona.js +7 -49
  19. package/dist/commands/push.js +3 -2
  20. package/dist/commands/sync.d.ts +29 -0
  21. package/dist/commands/sync.js +194 -0
  22. package/dist/commands/test.js +3 -5
  23. package/dist/interfaces/index.d.ts +2 -0
  24. package/dist/interfaces/lua.d.ts +26 -0
  25. package/dist/interfaces/lua.js +5 -0
  26. package/dist/interfaces/marketplace.d.ts +20 -0
  27. package/dist/interfaces/persona.d.ts +42 -0
  28. package/dist/interfaces/persona.js +5 -0
  29. package/dist/interfaces/user.d.ts +21 -0
  30. package/dist/types/index.d.ts +1 -0
  31. package/dist/types/skill.d.ts +1 -3
  32. package/dist/types/skill.js +3 -32
  33. package/dist/utils/agent-code-utils.d.ts +24 -0
  34. package/dist/utils/agent-code-utils.js +96 -0
  35. package/dist/utils/compile.js +8 -8
  36. package/dist/utils/dev-server.js +5 -4
  37. package/dist/utils/files.d.ts +1 -3
  38. package/dist/utils/files.js +1 -39
  39. package/dist/utils/init-helpers.d.ts +0 -8
  40. package/dist/utils/init-helpers.js +4 -37
  41. package/dist/utils/job-management.js +1 -2
  42. package/dist/utils/sandbox.d.ts +4 -3
  43. package/dist/utils/sandbox.js +5 -9
  44. package/dist/utils/sync-helpers.d.ts +61 -0
  45. package/dist/utils/sync-helpers.js +190 -0
  46. package/dist/utils/test-helpers.d.ts +0 -7
  47. package/dist/utils/test-helpers.js +0 -9
  48. package/package.json +3 -1
  49. package/template/README.md +1 -1
  50. package/template/lua.skill.yaml +10 -0
  51. package/template/package.json +1 -1
  52. package/dist/utils/agent-management.d.ts +0 -23
  53. package/dist/utils/agent-management.js +0 -67
@@ -3,16 +3,11 @@
3
3
  * Core types and classes for building Lua AI skills
4
4
  */
5
5
  import { assertValidToolName } from "./tool-validation.js";
6
- import fs from "fs";
7
- import path from "path";
8
- import yaml from "js-yaml";
9
6
  /**
10
7
  * Safe environment variable access function.
11
8
  * Gets injected at runtime with skill-specific environment variables.
12
9
  *
13
- * Checks in order:
14
- * 1. Process environment variables (.env file)
15
- * 2. lua.skill.yaml configuration
10
+ * Checks process environment variables (.env file)
16
11
  *
17
12
  * @param key - The environment variable key to retrieve
18
13
  * @returns The environment variable value or undefined if not found
@@ -24,32 +19,8 @@ import yaml from "js-yaml";
24
19
  * ```
25
20
  */
26
21
  export const env = (key) => {
27
- // Try to load environment variables from lua.skill.yaml
28
- try {
29
- // Check process.env first (.env file)
30
- if (process.env[key]) {
31
- return process.env[key];
32
- }
33
- // Look for lua.skill.yaml in current directory and parent directories
34
- let currentDir = process.cwd();
35
- let yamlPath = null;
36
- while (currentDir !== path.dirname(currentDir)) {
37
- const potentialPath = path.join(currentDir, 'lua.skill.yaml');
38
- if (fs.existsSync(potentialPath)) {
39
- yamlPath = potentialPath;
40
- break;
41
- }
42
- currentDir = path.dirname(currentDir);
43
- }
44
- if (yamlPath) {
45
- const yamlContent = fs.readFileSync(yamlPath, 'utf8');
46
- const config = yaml.load(yamlContent);
47
- return config?.skill?.env?.[key];
48
- }
49
- }
50
- catch (error) {
51
- // If we can't load the YAML, fall back to undefined
52
- console.warn(`Warning: Could not load environment variables from lua.skill.yaml: ${error}`);
22
+ if (process.env[key]) {
23
+ return process.env[key];
53
24
  }
54
25
  return undefined;
55
26
  };
@@ -0,0 +1,24 @@
1
+ export interface AgentCodeData {
2
+ name: string;
3
+ persona: string;
4
+ }
5
+ /**
6
+ * Load agent data (name, persona) from code (LuaAgent definition).
7
+ */
8
+ export declare function loadAgentFromCode(): AgentCodeData;
9
+ /**
10
+ * Save agent data (name and/or persona) into code (LuaAgent definition).
11
+ */
12
+ export declare function saveAgentToCode(data: Partial<AgentCodeData>): boolean;
13
+ /**
14
+ * Updates the LuaAgent configuration in the index.ts file.
15
+ *
16
+ * @param projectDir - Project directory containing src/index.ts
17
+ * @param data - Agent data to update (name and/or persona)
18
+ */
19
+ export declare function updateLuaAgentInCode(projectDir: string, data: Partial<AgentCodeData>): void;
20
+ export declare const loadNameFromCode: () => string;
21
+ export declare const loadPersonaFromCode: () => string;
22
+ export declare const saveNameToCode: (name: string) => boolean;
23
+ export declare const savePersonaToCode: (persona: string) => boolean;
24
+ export declare function updateLuaAgentInIndexFile(projectDir: string, agentName?: string, persona?: string): void;
@@ -0,0 +1,96 @@
1
+ import { Project, Node } from 'ts-morph';
2
+ import path from 'path';
3
+ import fs from 'fs';
4
+ import { findIndexFile, extractLuaAgentMetadata } from './compile.js';
5
+ /**
6
+ * Load agent data (name, persona) from code (LuaAgent definition).
7
+ */
8
+ export function loadAgentFromCode() {
9
+ try {
10
+ const indexPath = findIndexFile();
11
+ const project = new Project({
12
+ skipAddingFilesFromTsConfig: true,
13
+ });
14
+ const indexFile = project.addSourceFileAtPath(indexPath);
15
+ const metadata = extractLuaAgentMetadata(indexFile);
16
+ return {
17
+ name: metadata?.name || '',
18
+ persona: metadata?.persona || '',
19
+ };
20
+ }
21
+ catch (error) {
22
+ console.warn('Warning: Could not load agent from code:', error);
23
+ return { name: '', persona: '' };
24
+ }
25
+ }
26
+ /**
27
+ * Save agent data (name and/or persona) into code (LuaAgent definition).
28
+ */
29
+ export function saveAgentToCode(data) {
30
+ try {
31
+ updateLuaAgentInCode(process.cwd(), data);
32
+ return true;
33
+ }
34
+ catch (error) {
35
+ console.error('❌ Error saving agent to code:', error);
36
+ return false;
37
+ }
38
+ }
39
+ /**
40
+ * Updates the LuaAgent configuration in the index.ts file.
41
+ *
42
+ * @param projectDir - Project directory containing src/index.ts
43
+ * @param data - Agent data to update (name and/or persona)
44
+ */
45
+ export function updateLuaAgentInCode(projectDir, data) {
46
+ const indexPath = path.join(projectDir, 'src', 'index.ts');
47
+ if (!fs.existsSync(indexPath)) {
48
+ return;
49
+ }
50
+ try {
51
+ const project = new Project({ skipAddingFilesFromTsConfig: true });
52
+ const sourceFile = project.addSourceFileAtPath(indexPath);
53
+ sourceFile.forEachDescendant((node) => {
54
+ if (Node.isNewExpression(node) && node.getExpression().getText() === 'LuaAgent') {
55
+ const args = node.getArguments();
56
+ if (args.length > 0 && Node.isObjectLiteralExpression(args[0])) {
57
+ const configObj = args[0];
58
+ configObj.getProperties().forEach((prop) => {
59
+ if (Node.isPropertyAssignment(prop)) {
60
+ const propName = prop.getName();
61
+ if (data.name !== undefined && propName === 'name') {
62
+ const init = prop.getInitializer();
63
+ if (init) {
64
+ init.replaceWithText(`'${data.name.replace(/'/g, "\\'")}'`);
65
+ }
66
+ }
67
+ if (data.persona !== undefined && propName === 'persona') {
68
+ const init = prop.getInitializer();
69
+ if (init) {
70
+ const escaped = data.persona.replace(/`/g, '\\`').replace(/\$\{/g, '\\${');
71
+ init.replaceWithText(`\`${escaped}\``);
72
+ }
73
+ }
74
+ }
75
+ });
76
+ }
77
+ }
78
+ });
79
+ sourceFile.saveSync();
80
+ }
81
+ catch (error) {
82
+ console.warn('Warning: Could not update LuaAgent in index.ts');
83
+ }
84
+ }
85
+ // Legacy aliases for backward compatibility
86
+ export const loadNameFromCode = () => loadAgentFromCode().name;
87
+ export const loadPersonaFromCode = () => loadAgentFromCode().persona;
88
+ export const saveNameToCode = (name) => saveAgentToCode({ name });
89
+ export const savePersonaToCode = (persona) => saveAgentToCode({ persona });
90
+ // Re-export for init-helpers.ts compatibility
91
+ export function updateLuaAgentInIndexFile(projectDir, agentName, persona) {
92
+ updateLuaAgentInCode(projectDir, {
93
+ ...(agentName !== undefined && { name: agentName }),
94
+ ...(persona !== undefined && { persona })
95
+ });
96
+ }
@@ -520,16 +520,16 @@ export function extractLuaAgentMetadata(indexFile) {
520
520
  const propName = prop.getName();
521
521
  const value = prop.getInitializer();
522
522
  if (propName === 'name' && value) {
523
- name = value.getText().replace(/['"]/g, '');
523
+ // Use getLiteralValue for proper string extraction
524
+ if (Node.isStringLiteral(value) || Node.isNoSubstitutionTemplateLiteral(value)) {
525
+ name = value.getLiteralValue();
526
+ }
524
527
  }
525
528
  else if (propName === 'persona' && value) {
526
- // Handle multi-line strings and template literals
527
- const personaText = value.getText();
528
- persona = personaText
529
- .replace(/^['"`]/, '')
530
- .replace(/['"`]$/, '')
531
- .replace(/\\n/g, '\n')
532
- .trim();
529
+ // Use getLiteralValue to get actual string value (handles escapes correctly)
530
+ if (Node.isStringLiteral(value) || Node.isNoSubstitutionTemplateLiteral(value)) {
531
+ persona = value.getLiteralValue().trim();
532
+ }
533
533
  }
534
534
  else if (propName === 'skills' && value && Node.isArrayLiteralExpression(value)) {
535
535
  // Extract skill references from the array
@@ -7,7 +7,7 @@ import path from 'path';
7
7
  import { fileURLToPath } from 'url';
8
8
  import { createServer } from 'http';
9
9
  import { WebSocketServer } from 'ws';
10
- import { readSkillConfig, updateSkillYamlPersona } from './files.js';
10
+ import { readSkillConfig } from './files.js';
11
11
  import { executeTool, createBroadcastConsole, loadEnvironmentVariables } from './sandbox.js';
12
12
  import { getSandboxSkillId } from './sandbox-storage.js';
13
13
  import { sendChatMessage } from './dev-api.js';
@@ -17,6 +17,7 @@ import ProductApi from '../api/products.api.service.js';
17
17
  import BasketApi from '../api/basket.api.service.js';
18
18
  import OrderApi from '../api/order.api.service.js';
19
19
  import CustomDataApi from '../api/custom.data.api.service.js';
20
+ import { loadPersonaFromCode, savePersonaToCode } from './agent-code-utils.js';
20
21
  const __filename = fileURLToPath(import.meta.url);
21
22
  const __dirname = path.dirname(__filename);
22
23
  /**
@@ -200,8 +201,7 @@ function handleChatEndpoint(req, res, apiKey, agentId, skillId, sandboxId, deplo
200
201
  */
201
202
  function handleGetPersonaEndpoint(req, res) {
202
203
  try {
203
- const config = readSkillConfig();
204
- const persona = config?.agent?.persona || '';
204
+ const persona = loadPersonaFromCode();
205
205
  res.writeHead(HTTP_STATUS.OK, { 'Content-Type': 'application/json' });
206
206
  res.end(JSON.stringify({
207
207
  success: true,
@@ -224,7 +224,7 @@ function handlePostPersonaEndpoint(req, res) {
224
224
  req.on('end', async () => {
225
225
  try {
226
226
  const { persona } = JSON.parse(body);
227
- updateSkillYamlPersona(persona);
227
+ savePersonaToCode(persona);
228
228
  res.writeHead(HTTP_STATUS.OK, { 'Content-Type': 'application/json' });
229
229
  res.end(JSON.stringify({
230
230
  success: true,
@@ -520,6 +520,7 @@ function handleToolTestEndpoint(req, res, apiKey, agentId, wss) {
520
520
  inputs,
521
521
  apiKey,
522
522
  agentId,
523
+ channel: 'dev',
523
524
  customConsole
524
525
  });
525
526
  // Broadcast tool test completion
@@ -6,11 +6,9 @@
6
6
  * @param includeExamples - Whether to include the examples/ directory (default: false)
7
7
  */
8
8
  export declare function copyTemplateFiles(templateDir: string, targetDir: string, includeExamples?: boolean): void;
9
- export declare function createSkillYaml(agentId: string, orgId: string, skillName?: string, skillId?: string, persona?: string): void;
10
9
  export declare function readSkillYaml(): any;
11
10
  export declare function readSkillConfig(): any;
12
11
  /**
13
12
  * Update only the agent information in an existing YAML file
14
13
  */
15
- export declare function updateYamlAgent(agentId: string, orgId: string, persona?: string): void;
16
- export declare function updateSkillYamlPersona(persona: string): void;
14
+ export declare function updateYamlAgent(agentId: string, orgId: string): void;
@@ -64,18 +64,6 @@ function updatePackageJson(srcPath, destPath) {
64
64
  // Write the updated package.json
65
65
  fs.writeFileSync(destPath, JSON.stringify(templatePackageJson, null, 2) + '\n');
66
66
  }
67
- export function createSkillYaml(agentId, orgId, skillName, skillId, persona) {
68
- // Handle multiline strings properly for YAML
69
- const personaSection = persona ? ` persona: |\n${persona.split('\n').map(line => ` ${line}`).join('\n')}\n` : '';
70
- const yamlContent = `agent:
71
- agentId: "${agentId}"
72
- orgId: "${orgId}"
73
- ${personaSection}
74
- skills:
75
- # Skills will be auto-generated during compilation
76
- `;
77
- fs.writeFileSync("lua.skill.yaml", yamlContent);
78
- }
79
67
  export function readSkillYaml() {
80
68
  const yamlPath = path.join(process.cwd(), 'lua.skill.yaml');
81
69
  if (!fs.existsSync(yamlPath)) {
@@ -91,7 +79,7 @@ export function readSkillConfig() {
91
79
  /**
92
80
  * Update only the agent information in an existing YAML file
93
81
  */
94
- export function updateYamlAgent(agentId, orgId, persona) {
82
+ export function updateYamlAgent(agentId, orgId) {
95
83
  const yamlPath = path.join(process.cwd(), 'lua.skill.yaml');
96
84
  if (!fs.existsSync(yamlPath)) {
97
85
  throw new Error('lua.skill.yaml not found');
@@ -101,9 +89,6 @@ export function updateYamlAgent(agentId, orgId, persona) {
101
89
  config.agent = config.agent || {};
102
90
  config.agent.agentId = agentId;
103
91
  config.agent.orgId = orgId;
104
- if (persona) {
105
- config.agent.persona = persona;
106
- }
107
92
  // Write back to file
108
93
  const yamlContent = dump(config, {
109
94
  indent: 2,
@@ -112,26 +97,3 @@ export function updateYamlAgent(agentId, orgId, persona) {
112
97
  });
113
98
  fs.writeFileSync(yamlPath, yamlContent);
114
99
  }
115
- export function updateSkillYamlPersona(persona) {
116
- const yamlPath = path.join(process.cwd(), 'lua.skill.yaml');
117
- if (!fs.existsSync(yamlPath)) {
118
- console.error('❌ No lua.skill.yaml found. Please run this command from a skill directory.');
119
- return;
120
- }
121
- const yamlContent = fs.readFileSync(yamlPath, 'utf8');
122
- const data = load(yamlContent);
123
- // Update persona
124
- if (!data.agent) {
125
- data.agent = {};
126
- }
127
- data.agent.persona = persona;
128
- // Use yaml.dump to properly handle both old and new formats
129
- const updatedYamlContent = dump(data, {
130
- indent: 2,
131
- lineWidth: -1,
132
- noRefs: true,
133
- quotingType: '"',
134
- forceQuotes: false
135
- });
136
- fs.writeFileSync(yamlPath, updatedYamlContent);
137
- }
@@ -40,11 +40,3 @@ export declare function calculatePromptLines(baseCount: number, additionalLines:
40
40
  * @param lineCount - Number of lines to clear
41
41
  */
42
42
  export declare function clearLinesIfNeeded(lineCount: number): void;
43
- /**
44
- * Updates the LuaAgent configuration in the template's index.ts file
45
- *
46
- * @param projectDir - Project directory containing src/index.ts
47
- * @param agentName - Name of the agent
48
- * @param persona - Agent persona
49
- */
50
- export declare function updateLuaAgentInIndexFile(projectDir: string, agentName?: string, persona?: string): void;
@@ -4,10 +4,10 @@
4
4
  */
5
5
  import { fileURLToPath } from "url";
6
6
  import path from "path";
7
- import fs from "fs";
8
- import { copyTemplateFiles, createSkillYaml } from "./files.js";
7
+ import { copyTemplateFiles, updateYamlAgent } from "./files.js";
9
8
  import { clearPromptLines, writeProgress } from "./cli.js";
10
9
  import { execSync } from 'child_process';
10
+ import { updateLuaAgentInIndexFile } from './agent-code-utils.js';
11
11
  /**
12
12
  * Gets the template directory path.
13
13
  *
@@ -32,7 +32,8 @@ export function initializeProject(agentId, orgId, persona, agentName, withExampl
32
32
  const templateDir = getTemplateDir();
33
33
  const currentDir = process.cwd();
34
34
  copyTemplateFiles(templateDir, currentDir, withExamples);
35
- createSkillYaml(agentId, orgId, undefined, undefined, persona);
35
+ // Update the templated lua.skill.yaml with actual agent/org IDs
36
+ updateYamlAgent(agentId, orgId);
36
37
  // Update LuaAgent in index.ts with agent configuration
37
38
  updateLuaAgentInIndexFile(currentDir, agentName, persona);
38
39
  writeProgress("✅ Created lua.skill.yaml");
@@ -79,37 +80,3 @@ export function clearLinesIfNeeded(lineCount) {
79
80
  clearPromptLines(lineCount);
80
81
  }
81
82
  }
82
- /**
83
- * Updates the LuaAgent configuration in the template's index.ts file
84
- *
85
- * @param projectDir - Project directory containing src/index.ts
86
- * @param agentName - Name of the agent
87
- * @param persona - Agent persona
88
- */
89
- export function updateLuaAgentInIndexFile(projectDir, agentName, persona) {
90
- const indexPath = path.join(projectDir, 'src', 'index.ts');
91
- if (!fs.existsSync(indexPath)) {
92
- // If no index.ts, skip (might be an old template structure)
93
- return;
94
- }
95
- try {
96
- let content = fs.readFileSync(indexPath, 'utf8');
97
- // Check if LuaAgent exists in the file
98
- if (!content.includes('new LuaAgent(')) {
99
- return; // No LuaAgent to update
100
- }
101
- // Update agent name
102
- if (agentName) {
103
- content = content.replace(/name:\s*['"][^'"]*['"]/, `name: '${agentName.replace(/'/g, "\\'")}'`);
104
- }
105
- // Update persona
106
- if (persona) {
107
- content = content.replace(/(persona:\s*['"`])[\s\S]*?(['"`])/, `$1${persona.replace(/'/g, "\\'").replace(/`/g, '\\`')}$2`);
108
- }
109
- fs.writeFileSync(indexPath, content);
110
- }
111
- catch (error) {
112
- // Silently fail - not critical
113
- console.warn('Warning: Could not update LuaAgent in index.ts');
114
- }
115
- }
@@ -134,8 +134,7 @@ async function updateYamlWithJobs(config) {
134
134
  const cleanedJobs = jobs.map(job => ({
135
135
  name: job.name || '',
136
136
  version: job.version || SKILL_DEFAULTS.VERSION,
137
- jobId: job.jobId || '',
138
- schedule: job.schedule || { type: 'cron', expression: '0 0 * * *' }
137
+ jobId: job.jobId || ''
139
138
  }));
140
139
  // Update config with cleaned jobs array
141
140
  const updatedConfig = {
@@ -1,6 +1,8 @@
1
+ import { Channel } from "../interfaces/lua.js";
1
2
  export interface SandboxOptions {
2
3
  apiKey: string;
3
4
  agentId: string;
5
+ channel?: Channel;
4
6
  customConsole?: any;
5
7
  broadcastLog?: (logData: any) => void;
6
8
  }
@@ -21,19 +23,18 @@ export interface ExecuteJobOptions extends SandboxOptions {
21
23
  export interface ExecutePreProcessorOptions extends SandboxOptions {
22
24
  processorCode: string;
23
25
  messages: any[];
24
- channel: string;
26
+ channel: Channel;
25
27
  }
26
28
  export interface ExecutePostProcessorOptions extends SandboxOptions {
27
29
  processorCode: string;
28
30
  message: string;
29
31
  response: string;
30
- channel: string;
32
+ channel: Channel;
31
33
  }
32
34
  /**
33
35
  * Loads environment variables from multiple sources in priority order:
34
36
  * 1. process.env (lowest priority)
35
37
  * 2. .env file (medium priority)
36
- * 3. lua.skill.yaml env section (highest priority)
37
38
  */
38
39
  export declare function loadEnvironmentVariables(): Record<string, string>;
39
40
  /**
@@ -2,7 +2,6 @@ import { createRequire } from "module";
2
2
  import vm from "vm";
3
3
  import path from "path";
4
4
  import fs from "fs";
5
- import { readSkillConfig } from "./files.js";
6
5
  import UserDataApiService from "../api/user.data.api.service.js";
7
6
  import { BASE_URLS } from "../config/constants.js";
8
7
  import ProductApiService from "../api/products.api.service.js";
@@ -20,7 +19,6 @@ import { compressCode } from "./compile.js";
20
19
  * Loads environment variables from multiple sources in priority order:
21
20
  * 1. process.env (lowest priority)
22
21
  * 2. .env file (medium priority)
23
- * 3. lua.skill.yaml env section (highest priority)
24
22
  */
25
23
  export function loadEnvironmentVariables() {
26
24
  const envVars = {};
@@ -51,13 +49,6 @@ export function loadEnvironmentVariables() {
51
49
  console.warn('Warning: Could not read .env file:', error);
52
50
  }
53
51
  }
54
- // 3. Override with YAML config values (highest priority)
55
- const config = readSkillConfig();
56
- if (config?.skill?.env) {
57
- for (const [key, value] of Object.entries(config.skill.env)) {
58
- envVars[key] = value;
59
- }
60
- }
61
52
  return envVars;
62
53
  }
63
54
  /**
@@ -226,6 +217,11 @@ export function createSandbox(options) {
226
217
  null: null,
227
218
  Infinity: Infinity,
228
219
  NaN: NaN,
220
+ Lua: {
221
+ request: {
222
+ channel: options.channel ?? 'unknown',
223
+ },
224
+ },
229
225
  User: userService,
230
226
  Products: productService,
231
227
  Data: dataService,
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Sync Helpers
3
+ * Utilities for detecting drift between server state and local code
4
+ */
5
+ export interface PersonaDrift {
6
+ hasDrift: boolean;
7
+ serverPersona: string | null;
8
+ localPersona: string;
9
+ serverVersion?: number;
10
+ }
11
+ export interface NameDrift {
12
+ hasDrift: boolean;
13
+ serverName: string | null;
14
+ localName: string;
15
+ }
16
+ /**
17
+ * Fetch the latest published persona version from the server.
18
+ * Returns null if no persona is published or on error.
19
+ *
20
+ * Note: This returns the most recently published version, NOT the current/active one.
21
+ * The current version might be an older rollback, but code should match the latest push.
22
+ * Drafts are excluded since they haven't been deployed yet.
23
+ */
24
+ export declare function fetchServerPersona(apiKey: string, agentId: string): Promise<{
25
+ persona: string;
26
+ version: number;
27
+ } | null>;
28
+ /**
29
+ * Compare server persona with local persona.
30
+ * Returns true if they differ (drift detected).
31
+ */
32
+ export declare function comparePersona(serverPersona: string | null, localPersona: string): boolean;
33
+ /**
34
+ * Check for persona drift between server and local code.
35
+ * Returns drift info if drift detected, null otherwise.
36
+ */
37
+ export declare function checkPersonaDrift(apiKey: string, agentId: string): Promise<PersonaDrift | null>;
38
+ /**
39
+ * Display a colored diff between two strings.
40
+ */
41
+ export declare function showColoredDiff(oldText: string, newText: string, oldLabel?: string, newLabel?: string): void;
42
+ /**
43
+ * Display a diff between server and local persona.
44
+ */
45
+ export declare function showPersonaDiff(serverPersona: string | null, localPersona: string): void;
46
+ /**
47
+ * Display a compact drift warning for compile flow.
48
+ */
49
+ export declare function showDriftWarning(drift: PersonaDrift): void;
50
+ /**
51
+ * Fetch the agent name from the server.
52
+ */
53
+ export declare function fetchServerName(apiKey: string, agentId: string): Promise<string | null>;
54
+ /**
55
+ * Check for name drift between server and local code.
56
+ */
57
+ export declare function checkNameDrift(apiKey: string, agentId: string): Promise<NameDrift | null>;
58
+ /**
59
+ * Display name drift info.
60
+ */
61
+ export declare function showNameDiff(serverName: string | null, localName: string): void;