@ericnunes/frame-code-cli 0.0.5 → 0.0.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/README.md CHANGED
@@ -46,17 +46,29 @@ frame-code --help
46
46
 
47
47
  Executa o agente em modo interativo, onde você pode conversar com o agente em tempo real.
48
48
 
49
- ```bash
50
- frame-code interactive
51
- ```
49
+ ```bash
50
+ frame-code interactive
51
+ ```
52
+
53
+ Com contexto de sessão no Langfuse:
54
+
55
+ ```bash
56
+ frame-code interactive --session-id sessao-001 --user-id user-001
57
+ ```
52
58
 
53
59
  ### Modo Autônomo
54
60
 
55
61
  Executa o agente em modo autônomo, onde ele trabalha de forma independente em uma tarefa.
56
62
 
57
- ```bash
58
- frame-code autonomous
59
- ```
63
+ ```bash
64
+ frame-code autonomous
65
+ ```
66
+
67
+ Com sessão explícita:
68
+
69
+ ```bash
70
+ frame-code autonomous --session-id sessao-001 --user-id user-001 "implemente uma API REST simples"
71
+ ```
60
72
 
61
73
  ### Modo Multi-Agente
62
74
 
package/dist/app/cli.js CHANGED
@@ -7,10 +7,20 @@ const commander_1 = require("commander");
7
7
  const autonomous_1 = require("../cli/commands/autonomous");
8
8
  const interactive_1 = require("../cli/commands/interactive");
9
9
  const memory_1 = require("../cli/commands/memory");
10
+ function resolveCliVersion() {
11
+ try {
12
+ const pkg = require('../../package.json');
13
+ if (pkg && typeof pkg.version === 'string' && pkg.version.trim().length > 0) {
14
+ return pkg.version;
15
+ }
16
+ }
17
+ catch { }
18
+ return '0.0.0';
19
+ }
10
20
  exports.program = new commander_1.Command()
11
21
  .name('frame-code-cli')
12
22
  .description('CLI para frame-code com agentes')
13
- .version('0.0.1');
23
+ .version(resolveCliVersion());
14
24
  exports.program.addCommand((0, autonomous_1.createAutonomousCommand)());
15
25
  exports.program.addCommand((0, interactive_1.createInteractiveCommand)());
16
26
  exports.program.addCommand(memory_1.memoryCommand);
@@ -11,6 +11,7 @@ const reader_1 = require("../input/reader");
11
11
  const attachments_1 = require("../input/images/attachments");
12
12
  const agent_runtime_1 = require("../../agent-runtime");
13
13
  const cliTelemetry_1 = require("../../infrastructure/telemetry/cliTelemetry");
14
+ const frame_agent_core_1 = require("@ericnunes/frame-agent-core");
14
15
  const STATUS_RUNNING = 'RUNNING';
15
16
  const STATUS_FINISHED = 'FINISHED';
16
17
  const STATUS_ERROR = 'ERROR';
@@ -52,6 +53,10 @@ async function processAutonomousInput(input, options) {
52
53
  logger_1.logger.debug('[Autonomous] Mensagens iniciais:', JSON.stringify(messages, null, 2));
53
54
  const initialState = {
54
55
  messages,
56
+ metadata: {
57
+ ...(options._sessionId ? { sessionId: options._sessionId } : {}),
58
+ ...(options._userId ? { userId: options._userId } : {}),
59
+ },
55
60
  data: {
56
61
  ...(options._runId ? { runId: options._runId } : {}),
57
62
  ...(imagePaths.length ? { imagePaths, imageDetail } : {})
@@ -104,6 +109,8 @@ function createAutonomousCommand() {
104
109
  .option('-a, --agent <name>', 'Agente a ser usado (alternativa ao argumento posicional)')
105
110
  .option('--image <path>', 'Caminho de imagem local (pode repetir)', collect, [])
106
111
  .option('--image-detail <low|high|auto>', 'Nivel de detalhe para imagem (low|high|auto)', 'auto')
112
+ .option('--session-id <id>', 'Session ID para agrupar traces no Langfuse (default: UUID automático)')
113
+ .option('--user-id <id>', 'User ID associado aos traces da sessão')
107
114
  .action(async (agentArg, additionalInput, options) => {
108
115
  try {
109
116
  await (0, config_1.loadConfig)();
@@ -137,12 +144,20 @@ function createAutonomousCommand() {
137
144
  options._runId = staged.runId;
138
145
  options._imagePaths = staged.stagedPaths;
139
146
  }
147
+ const sessionContext = frame_agent_core_1.telemetry.resolveSessionTelemetryContext({
148
+ sessionId: options.sessionId,
149
+ userId: options.userId,
150
+ });
151
+ options._sessionId = sessionContext.sessionId;
152
+ options._userId = sessionContext.userId;
140
153
  if (options.agent) {
141
154
  logger_1.logger.info(`[Autonomous] Usando agente: ${options.agent}`);
142
155
  }
143
156
  else {
144
157
  logger_1.logger.info(`[Autonomous] Usando agente padrão`);
145
158
  }
159
+ logger_1.logger.info(`[Autonomous] Telemetria sessionId=${sessionContext.sessionId}` +
160
+ (sessionContext.userId ? ` userId=${sessionContext.userId}` : ''));
146
161
  if (resolvedInput) {
147
162
  logger_1.logger.info(`[Autonomous] Input prioritário: ${resolvedInput.substring(0, 100)}...`);
148
163
  }
@@ -11,6 +11,7 @@ const tools_1 = require("../../tools");
11
11
  const config_1 = require("../../infrastructure/config");
12
12
  const agent_runtime_1 = require("../../agent-runtime");
13
13
  const cliTelemetry_1 = require("../../infrastructure/telemetry/cliTelemetry");
14
+ const frame_agent_core_1 = require("@ericnunes/frame-agent-core");
14
15
  function extractAnswer(result) {
15
16
  const lastToolCall = result?.state?.lastToolCall;
16
17
  if (lastToolCall?.toolName === 'final_answer' && typeof lastToolCall?.params?.answer === 'string') {
@@ -25,6 +26,8 @@ function createInteractiveCommand() {
25
26
  const command = new commander_1.Command('interactive')
26
27
  .description('Executa o agente em modo interativo (loop de perguntas/respostas)')
27
28
  .option('-a, --agent <name>', 'Agente a ser usado (default: primeiro main-agent encontrado)')
29
+ .option('--session-id <id>', 'Session ID para agrupar traces no Langfuse (default: UUID automático)')
30
+ .option('--user-id <id>', 'User ID associado aos traces da sessão')
28
31
  .option('-v, --verbose', 'Logs detalhados')
29
32
  .action(async (options) => {
30
33
  try {
@@ -41,9 +44,15 @@ function createInteractiveCommand() {
41
44
  throw new Error(`Agente "${agentName}" nao encontrado.`);
42
45
  if (meta.type !== 'main-agent')
43
46
  throw new Error(`Agente "${agentName}" nao eh main-agent.`);
47
+ const sessionContext = frame_agent_core_1.telemetry.resolveSessionTelemetryContext({
48
+ sessionId: options.sessionId,
49
+ userId: options.userId,
50
+ });
44
51
  const runtimeTelemetry = (0, cliTelemetry_1.createCliTelemetry)();
45
52
  const engine = await registry.createEngine(agentName, runtimeTelemetry);
46
53
  logger_1.logger.info(`[Interactive] Agente: ${agentName}`);
54
+ logger_1.logger.info(`[Interactive] Telemetria sessionId=${sessionContext.sessionId}` +
55
+ (sessionContext.userId ? ` userId=${sessionContext.userId}` : ''));
47
56
  logger_1.logger.info('[Interactive] Digite sua mensagem. Use "exit" para sair.');
48
57
  let currentState;
49
58
  const rl = readline_1.default.createInterface({ input: process.stdin, output: process.stdout });
@@ -60,6 +69,10 @@ function createInteractiveCommand() {
60
69
  if (!currentState) {
61
70
  result = await engine.execute({
62
71
  messages: [{ role: 'user', content: input }],
72
+ metadata: {
73
+ sessionId: sessionContext.sessionId,
74
+ ...(sessionContext.userId ? { userId: sessionContext.userId } : {}),
75
+ },
63
76
  status: 'RUNNING',
64
77
  });
65
78
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ericnunes/frame-code-cli",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "CLI para interagir com agentes (runtime via frame-agent-core)",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -44,7 +44,7 @@
44
44
  "author": "Eric Nunes",
45
45
  "license": "SEE LICENSE IN LICENSE",
46
46
  "dependencies": {
47
- "@ericnunes/frame-agent-core": ">=0.0.5 <0.1.0",
47
+ "@ericnunes/frame-agent-core": ">=0.0.7 <0.1.0",
48
48
  "commander": "^14.0.1",
49
49
  "dotenv": "^17.2.3"
50
50
  },