File size: 4,860 Bytes
95eb75a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// ─── Agent action tools — remember, recall, propose_action, get_datetime, generate_qr, send_notification, schedule_task ───────────────────────────────────────────────────────────
  // P3-4 split da toolDefinitions.ts — DO NOT edit toolDefinitions.ts directly
  // Tools (7): remember, recall, propose_action, get_datetime, generate_qr, send_notification, schedule_task

  import type { ChatCompletionTool } from "openai/resources/chat/completions";

  export const AGENT_ACTION_TOOLS: (ChatCompletionTool | undefined)[] = [
      {
      type: "function",
      function: {
        name: "remember",
        description: "Salva informazioni in memoria persistente tra sessioni (localStorage).",
        parameters: { type: "object", properties: { key: { type: "string" }, value: { type: "string" }, category: { type: "string", description: "Categoria (default: general)" } }, required: ["key","value"] }
      }
    },
    {
      type: "function",
      function: {
        name: "recall",
        description: "Recupera informazioni dalla memoria persistente.",
        parameters: { type: "object", properties: { key: { type: "string", description: "Chiave specifica" }, category: { type: "string", description: "Categoria" } } }
      }
    },
    {
      type: "function",
      function: {
        name: "propose_action",
        description: "Proponi all'utente un'azione concreta da eseguire come step successivo (mostra bottone Procedi).",
        parameters: { type: "object", properties: { label: { type: "string", description: "Label breve (es. 'Crea README.md')" }, prompt: { type: "string", description: "Prompt completo che l'AI riceverà su click" }, preview: { type: "string", description: "Anteprima breve" } }, required: ["label","prompt"] }
      }
    },
    {
      type: "function",
      function: {
        name: "get_datetime",
        description: "Restituisce la data e ora correnti con fuso orario. Usa quando l'utente chiede che ora è, che giorno è, la data di oggi.",
        parameters: { type: "object", properties: { timezone: { type: "string", description: "Fuso orario IANA (es. 'Europe/Rome', 'America/New_York'). Default: Europe/Rome" } } }
      }
    },
    {
      type: "function",
      function: {
        name: "generate_qr",
        description: "Genera un QR code da testo o URL e lo mostra inline nella chat (qrserver.com, gratis).",
        parameters: {
          type: "object",
          properties: {
            text: { type: "string", description: "Testo o URL da codificare nel QR" },
            size: { type: "number",  description: "Dimensione in pixel (default 250, max 500)" }
          },
          required: ["text"]
        }
      }
    },
    {
      type: "function",
      function: {
        name: "send_notification",
        description: "Invia una notifica push nativa del browser all'utente. Utile per segnalare il completamento di task lunghi.",
        parameters: {
          type: "object",
          properties: {
            title: { type: "string", description: "Titolo della notifica" },
            body:  { type: "string", description: "Testo del corpo (opzionale)" }
          },
          required: ["title"]
        }
      }
    },
  {
    type: 'function',
    function: {
      name: 'schedule_task',
      description:
        "Pianifica un task che l'agente eseguirà automaticamente in futuro. " +
        "Usa quando l'utente chiede 'ricordami di...', 'ogni giorno fai...', " +
        "'alle 8 di mattina controlla...', 'tra 2 ore cerca...'. " +
        'Il task viene salvato in modo persistente e sopravvive alla chiusura dell\'app.',
      parameters: {
        type: 'object',
        properties: {
          label: {
            type: 'string',
            description: 'Nome breve del task (es. "Notizie del mattino", "Reminder meteo")',
          },
          goal: {
            type: 'string',
            description:
              "Il task che l'agente dovrà eseguire, scritto come se fosse un messaggio utente. " +
              'Es. "Cerca le notizie di oggi e riassumile in 5 punti" oppure ' +
              '"Controlla il meteo a Milano e avvisami se piove".',
          },
          when: {
            type: 'string',
            description:
              'Quando eseguire il task, in linguaggio naturale italiano. ' +
              'Esempi: "ogni giorno alle 8:00", "tra 2 ore", "ogni 30 minuti", ' +
              '"al prossimo avvio", "domani alle 9:30".',
          },
          notify: {
            type: 'boolean',
            description: 'Se true, invia una notifica push al completamento (default: true).',
          },
        },
        required: ['label', 'goal', 'when'],
      },
    },
  },
  ];