mirror of
https://github.com/R0m1k3/Loki.git
synced 2026-10-24 15:38:12 +02:00
v0.8.7 : envoyer et recevoir des fichiers dans le chat
Les fichiers circulent enfin dans les deux sens. Envoi : trombone dans le composeur, glisser-deposer sur toute la fenetre, ou Ctrl+V. Le fichier est depose dans uploads/ du dossier de travail de l'agent et son chemin est annonce au modele, qui en fait ce qu'il veut avec ses outils. Rien n'est interprete au passage, donc tout type de fichier passe. Le depot n'a lieu qu'a l'ENVOI du message : retirer un fichier de la liste ne laisse aucune trace sur le disque. Transport en base64 dans du JSON et non en multipart, seule forme que le tunnel E2E dispatche : l'acces distant marche sans code specifique. Reception : le modele ecrit un lien Markdown ordinaire vers un fichier de son dossier de travail, et le clic telecharge. Il repondait jusqu'ici par un chemin serveur, inutilisable depuis un navigateur. Le clic passe par fetch + blob (la cle de pilotage voyage dans un en-tete qu'une navigation ne porterait pas, et le chemin de base change derriere le tunnel). Markdown refusant les espaces non echappes dans une cible de lien, ils sont encodes avant rendu : sans ca [x](mon rapport.pdf) ne produisait rien du tout. Perimetre du telechargement strictement limite au dossier de travail : '..', chemins absolus et liens symboliques qui en sortent sont refuses, et le fichier est toujours servi en piece jointe avec nosniff — un .html produit par le modele ne doit pas s'executer dans l'origine de l'UI, ou il lirait la cle de pilotage. Preambule du mode agent : ~2350 -> ~1770 tokens, sans perdre une regle. Le poids etait dans les schemas d'outils (le double du prompt), pas dans le prompt. Celui-ci reenumerait des outils que les schemas decrivent deja, et la regle « write, jamais echo » y figurait trois fois. Trois tests gardent le budget : ce prompt a deja regrossi ligne par ligne deux fois. Aussi : l'export mentionne les pieces jointes (un message sans texte donnait une section vide), et le decompte de contexte perd le mot « contexte » au profit du nom du modele.
This commit is contained in:
1 parent
5a4c33661d
commit
6807bad48d
23 files changed
+1363
-104
No files matched your search
@@ -56,12 +56,12 @@ func memSearchTool() Tool {
|
||||
Type: "function",
|
||||
Function: ToolFunction{
|
||||
Name: "mem_search",
|
||||
Description: "Search your memory (Markdown pages under memory/). Returns a ranked list of {file, title, snippet}. Use it FIRST when the user mentions something you might already know (preferences, ongoing projects, past decisions). Follow up with mem_read on the most relevant page.",
|
||||
Description: "Search your memory (Markdown pages under memory/) → ranked {file, title, snippet}. Use FIRST when the user mentions something you might already know, then mem_read the best page.",
|
||||
Parameters: map[string]any{
|
||||
"type": "object",
|
||||
"properties": map[string]any{
|
||||
"query": map[string]any{"type": "string", "description": "Keywords or a short phrase"},
|
||||
"limit": map[string]any{"type": "integer", "description": "Max results (default 8, max 30)"},
|
||||
"query": map[string]any{"type": "string", "description": "Keywords"},
|
||||
"limit": map[string]any{"type": "integer", "description": "Default 8, max 30"},
|
||||
},
|
||||
"required": []string{"query"},
|
||||
},
|
||||
@@ -74,13 +74,13 @@ func memReadTool() Tool {
|
||||
Type: "function",
|
||||
Function: ToolFunction{
|
||||
Name: "mem_read",
|
||||
Description: "Read a memory page (Markdown file). 1-indexed output, lines prefixed with their number. offset/limit for long pages.",
|
||||
Description: "Read a memory page. Lines prefixed with their 1-indexed number; offset/limit for long pages.",
|
||||
Parameters: map[string]any{
|
||||
"type": "object",
|
||||
"properties": map[string]any{
|
||||
"file": map[string]any{"type": "string", "description": "Page name (e.g. docker-notes.md)"},
|
||||
"offset": map[string]any{"type": "integer", "description": "Start line (1-indexed, default 1)"},
|
||||
"limit": map[string]any{"type": "integer", "description": "Number of lines (default 500, max 500)"},
|
||||
"offset": map[string]any{"type": "integer", "description": "Start line (default 1)"},
|
||||
"limit": map[string]any{"type": "integer", "description": "Lines (max 500)"},
|
||||
},
|
||||
"required": []string{"file"},
|
||||
},
|
||||
@@ -93,12 +93,12 @@ func memAddTool() Tool {
|
||||
Type: "function",
|
||||
Function: ToolFunction{
|
||||
Name: "mem_add",
|
||||
Description: "Create a new memory page (Markdown). One topic per page, descriptive kebab-case name. First line = short title (#). Refuses to overwrite an existing page (use mem_edit).",
|
||||
Description: "Create a memory page. One topic per page, kebab-case name, first line = title (#). Refuses to overwrite an existing page (use mem_edit).",
|
||||
Parameters: map[string]any{
|
||||
"type": "object",
|
||||
"properties": map[string]any{
|
||||
"file": map[string]any{"type": "string", "description": "Page name (e.g. docker-notes.md)"},
|
||||
"content": map[string]any{"type": "string", "description": "Markdown content (first line = title #)"},
|
||||
"file": map[string]any{"type": "string", "description": "Page name"},
|
||||
"content": map[string]any{"type": "string", "description": "Markdown, first line = title #"},
|
||||
},
|
||||
"required": []string{"file", "content"},
|
||||
},
|
||||
@@ -111,13 +111,13 @@ func memEditTool() Tool {
|
||||
Type: "function",
|
||||
Function: ToolFunction{
|
||||
Name: "mem_edit",
|
||||
Description: "Edit a memory page by exact replacement: old → new. old must appear EXACTLY once in the page (add context to make it unique). To append, put the current end of the page in old and the extended version in new.",
|
||||
Description: "Patch a memory page: old → new, old unique in the page. To append, put the current end of the page in old and the extended version in new.",
|
||||
Parameters: map[string]any{
|
||||
"type": "object",
|
||||
"properties": map[string]any{
|
||||
"file": map[string]any{"type": "string", "description": "Page name"},
|
||||
"old": map[string]any{"type": "string", "description": "Exact text to replace (unique in the page)"},
|
||||
"new": map[string]any{"type": "string", "description": "Replacement text"},
|
||||
"old": map[string]any{"type": "string", "description": "Exact text to replace (unique)"},
|
||||
"new": map[string]any{"type": "string", "description": "Replacement"},
|
||||
},
|
||||
"required": []string{"file", "old", "new"},
|
||||
},
|
||||
@@ -130,13 +130,13 @@ func editTool() Tool {
|
||||
Type: "function",
|
||||
Function: ToolFunction{
|
||||
Name: "edit",
|
||||
Description: "Modify a file on disk by exact replacement: old → new. old must appear EXACTLY once in the file (add surrounding context to make it unique). Prefer this over rewriting the whole file — it avoids retyping everything.",
|
||||
Description: "Patch a file by exact replacement: old → new. old must appear EXACTLY once (add context to make it unique). Prefer this over rewriting a whole file.",
|
||||
Parameters: map[string]any{
|
||||
"type": "object",
|
||||
"properties": map[string]any{
|
||||
"file": map[string]any{"type": "string", "description": "Path of the file to modify"},
|
||||
"old": map[string]any{"type": "string", "description": "Exact text to replace (unique in the file)"},
|
||||
"new": map[string]any{"type": "string", "description": "Replacement text"},
|
||||
"file": map[string]any{"type": "string", "description": "Path"},
|
||||
"old": map[string]any{"type": "string", "description": "Exact text to replace (unique)"},
|
||||
"new": map[string]any{"type": "string", "description": "Replacement"},
|
||||
},
|
||||
"required": []string{"file", "old", "new"},
|
||||
},
|
||||
@@ -149,12 +149,12 @@ func writeTool() Tool {
|
||||
Type: "function",
|
||||
Function: ToolFunction{
|
||||
Name: "write",
|
||||
Description: "Write a file on disk with the exact content given (creates it, or replaces it whole; parent directories are created). ALWAYS use this to create a script or any text file — NEVER build a file through the shell with echo, cat, python -c or Set-Content: the shell mangles quotes and breaks the file. Content is written verbatim, no escaping needed.",
|
||||
Description: "Create or replace a file with the exact content given (parent dirs created, content verbatim, no escaping). ALWAYS use this for a script or any text file — NEVER build one through the shell with echo, cat, python -c or Set-Content: quoting breaks.",
|
||||
Parameters: map[string]any{
|
||||
"type": "object",
|
||||
"properties": map[string]any{
|
||||
"file": map[string]any{"type": "string", "description": "Path of the file to write"},
|
||||
"content": map[string]any{"type": "string", "description": "Full content of the file, verbatim"},
|
||||
"file": map[string]any{"type": "string", "description": "Path"},
|
||||
"content": map[string]any{"type": "string", "description": "Full content"},
|
||||
},
|
||||
"required": []string{"file", "content"},
|
||||
},
|
||||
@@ -167,11 +167,11 @@ func bashTool() Tool {
|
||||
Type: "function",
|
||||
Function: ToolFunction{
|
||||
Name: "bash",
|
||||
Description: "Execute a shell command on this machine (" + shellName() + ") and return stdout, stderr and the exit code. Use " + shellName() + " syntax, not another shell's. For inspecting the system, running scripts, reading files, reading logs. To CREATE or REWRITE a file, use the write tool instead — never echo/cat/python -c. Avoid destructive commands unless explicitly asked.",
|
||||
Description: "Run a shell command (" + shellName() + " syntax) and return stdout, stderr and exit code: inspect the system, read files and logs, run scripts. To CREATE or REWRITE a file use write instead — never echo/cat/python -c. Avoid destructive commands unless asked.",
|
||||
Parameters: map[string]any{
|
||||
"type": "object",
|
||||
"properties": map[string]any{
|
||||
"command": map[string]any{"type": "string", "description": "The bash command"},
|
||||
"command": map[string]any{"type": "string", "description": "The command"},
|
||||
"timeout": map[string]any{"type": "integer", "description": fmt.Sprintf("Timeout s (default %d, max %d)", toolDefaultTimeout, toolMaxTimeout)},
|
||||
},
|
||||
"required": []string{"command"},
|
||||
|
||||
Reference in new issue
Block a user