@triplef/agent 3.0.0 → 3.1.0

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.
@@ -1,5 +1,5 @@
1
1
  import { VariantName, IntentResult, TemplateName, FormatZodShapeOptions } from '../schemas/index.js';
2
- export { D as DEFAULT_VARIANT_ID } from '../format-zod-shape.types-wf6Pwdvx.js';
2
+ export { D as DEFAULT_VARIANT_ID } from '../format-zod-shape.types-DbOhrGEO.js';
3
3
  import { MemoryPoint } from '../tools/index.js';
4
4
  import * as zod from 'zod';
5
5
  import { z, ZodTypeAny, ZodType } from 'zod';
@@ -76,6 +76,8 @@ interface ObsidianCurationPromptOptions {
76
76
  autonomous: boolean;
77
77
  workingNotePath?: string;
78
78
  defaultFolder?: string;
79
+ conversationId?: string;
80
+ conversationFolder?: string;
79
81
  }
80
82
 
81
83
  declare function buildObsidianCurationPrompt(options: ObsidianCurationPromptOptions): string;
@@ -2861,22 +2861,29 @@ ${capped}`;
2861
2861
 
2862
2862
  // src/prompts/harness/obsidian-curation.prompt.ts
2863
2863
  function buildObsidianCurationPrompt(options) {
2864
+ const defaultFolder = options.defaultFolder ?? "tripleF";
2864
2865
  const workingNote = options.workingNotePath ? `The user explicitly adopted the working note ${options.workingNotePath}. Read its latest content before extending it. If it is confirmed missing, resolve the topic through search; if Obsidian is unreachable, retain this path for later.` : "No working note is explicitly bound to this conversation.";
2865
- const autonomy = options.autonomous ? `AUTONOMOUS PERMISSION: The user enabled Obsidian for this conversation. You may decide to create or update a note without asking again when the completed result is substantial and reusable: a game design, mechanics/logic/levels, an implementation plan, a technical design, synthesized research, or a durable reference. Doing nothing is valid and expected for small talk, trivial answers, incomplete drafts, or redundant material. Never save raw searches, reasoning, rejected alternatives, tool logs, or chat filler. Search first when an artifact may already exist. Create beneath the configured default folder unless an explicitly adopted working note authorizes an update elsewhere. Never delete or open the Obsidian UI autonomously.` : `EXPLICIT OPERATION: Perform only the Obsidian operation the user requested. Positive feedback alone is not a save request. If the target cannot be resolved unambiguously, ask the user to choose instead of guessing.`;
2866
+ const conversationFolder = options.conversationFolder ? `The established conversation folder is "${options.conversationFolder}". Reuse this exact folder for every new note belonging to this conversation. Search within it before creating, keep all nested branches beneath it, and never create or adopt a second conversation folder.` : options.conversationId ? `No conversation folder has been established. The exact conversation identifier is "${options.conversationId}". Before the first new artifact, choose one concise, meaningful Topic from the conversation and use "<Topic> - ${options.conversationId}" as the single top-level conversation folder beneath "${defaultFolder}". Create "<defaultFolder>/<Topic> - ${options.conversationId}/<Topic> Overview.md" first and set conversationRoot to true on that create call only. The full identifier suffix is mandatory and case-sensitive. Never add the identifier to notes or nested folders, never shorten it, and never use numeric, random, copy, or date suffixes instead. Once creation succeeds, reuse that exact folder for the rest of the conversation. An already_exists result for this exact root confirms an earlier attempt: keep the same folder, read before updating, and never choose an alternate suffix.` : "No conversation folder or conversation identifier is available. Never invent an identifier or an unsuffixed conversation folder. You may perform a read, update, or an explicitly requested single-note create at a validated user-supplied destination. For a new hierarchy, ask for clarification; for autonomous hierarchy creation, return NO_ACTION.";
2867
+ const autonomy = options.autonomous ? `AUTONOMOUS PERMISSION: The user enabled Obsidian for this conversation. You may decide to create or update a note without asking again when the completed result is substantial and reusable: a game design, mechanics/logic/levels, an implementation plan, a technical design, synthesized research, or a durable reference. Doing nothing is valid and expected for small talk, trivial answers, incomplete drafts, or redundant material. Never save raw searches, reasoning, rejected alternatives, tool logs, or chat filler. Search first when an artifact may already exist. Create within the established conversation folder or establish one beneath the configured default folder; an explicitly adopted working note authorizes an update elsewhere. Never delete or open the Obsidian UI autonomously.` : `EXPLICIT OPERATION: Perform only the Obsidian operation the user requested. Positive feedback alone is not a save request. If the target cannot be resolved unambiguously, ask the user to choose instead of guessing.`;
2866
2868
  return `OBSIDIAN POLICY
2867
2869
  ${workingNote}
2868
- The configured default folder is "${options.defaultFolder ?? "tripleF"}".
2870
+ The configured default folder is "${defaultFolder}".
2871
+ ${conversationFolder}
2869
2872
  ${autonomy}
2870
2873
 
2871
- Resolve targets in this order: an explicit validated path; explicit title and folder; the bound working note; one unambiguous search match; then a concise descriptive title beneath the default folder. Multiple plausible matches, an unclear outside-folder destination, or a filename collision about another topic require clarification. Never overwrite a collision or invent numeric suffixes.
2874
+ Resolve targets in this order: an explicit validated path; explicit title and folder; the bound working note; one unambiguous search match; then a concise descriptive title within the conversation folder. Multiple plausible matches, an unclear outside-folder destination, or a filename collision about another topic require clarification. Never overwrite a collision or invent numeric, copy, or random suffixes.
2872
2875
 
2873
- DEFAULT NOTE STRUCTURE: For substantial multi-part content, create a bounded hierarchy of linked notes instead of one monolithic note. Put the root at "<defaultFolder>/<Topic>.md", category notes at "<defaultFolder>/<Topic>/<Category>.md", subcategory notes at "<defaultFolder>/<Topic>/<Category>/<Subcategory>.md", and deeper descendants only when the content justifies them. Create the root note first, then its useful branches. A parent note contains a concise overview of its own scope and a ## Contents list of full-path Wikilinks such as [[tripleF/My Game/Characters|Characters]] and [[tripleF/My Game/Regions/Deserts|Deserts]]. Do not duplicate descendant content in ancestor notes. Create only categories supported by the requested content; any game categories in examples are illustrative, never a fixed taxonomy. No empty placeholder notes or arbitrary depth. A Wikilink or planned path never proves that a note was created; every note requires its own successful tool result.
2876
+ DEFAULT NOTE STRUCTURE: Every newly curated artifact without an explicit outside-folder destination belongs to the conversation folder. For substantial multi-part content, create a bounded hierarchy of linked notes instead of one monolithic note. Put the root at "<defaultFolder>/<Topic> - <conversationId>/<Topic> Overview.md", category overviews at "<conversationFolder>/<Category>/<Category> Overview.md", and subcategory overviews at "<conversationFolder>/<Category>/<Subcategory>/<Subcategory> Overview.md". Put leaf notes inside their nearest branch folder. Create the root note first with conversationRoot true, then useful branch overviews before their leaves. A parent note contains a concise overview of its own scope and a ## Contents list of full-path Wikilinks such as [[tripleF/My Game - conv-123/Regions/Regions Overview|Regions]] and [[tripleF/My Game - conv-123/Regions/Deserts/Deserts Overview|Deserts]]. Do not duplicate descendant content in ancestor notes. Create only categories supported by the requested content; any game categories in examples are illustrative, never a fixed taxonomy. No empty placeholder notes or arbitrary depth. A Wikilink or planned path never proves that a note was created; every note requires its own successful tool result.
2874
2877
 
2875
- SINGLE-NOTE OVERRIDE: An explicit request such as "one note", "single note", "store everything in one note", or "keep everything together" overrides the hierarchy default. Put all requested content in the requested or bound note using ## and deeper headings, and create no category or child notes.
2878
+ NOTE AND FOLDER NAMES: A note basename must never equal any folder segment in its destination path, case-insensitively. Use "<Topic> Overview", "<Category> Overview", and "<Subcategory> Overview" for branch notes instead of names identical to their folders. Do not create a folder whose name matches an existing sibling note basename. If nesting beneath a legacy note such as ".../Regions/Deserts.md" would require a conflicting ".../Regions/Deserts/" folder, stop and clarify rather than moving or renaming the existing note.
2876
2879
 
2877
- EXTEND EXISTING HIERARCHIES: A request such as "Create Glass Dunes under Deserts" authorizes a child note and a navigation-link update to its parent. Resolve Deserts from the current hierarchy or conversation context, then search if needed. For one unambiguous match at ".../Regions/Deserts.md", create ".../Regions/Deserts/Glass Dunes.md", then read the parent's latest content and add a full-path link with a conditional update. Multiple plausible Deserts matches require clarification. If the requested branch is missing, create the missing branch only when its intended parent is unambiguous; otherwise clarify. The same rule applies recursively beneath any category or leaf. Never automatically move or restructure existing notes.
2880
+ SINGLE-NOTE OVERRIDE: An explicit request such as "one note", "single note", "store everything in one note", or "keep everything together" overrides the hierarchy default. Put all requested content in the requested or bound note using ## and deeper headings, and create no category or child notes. For a new artifact without an explicit destination, the conversation root overview is the single note; still use the required conversation folder and conversationRoot marker.
2878
2881
 
2879
- For create-if-missing, search first and use an unambiguous existing note instead of duplicating it. For extend-or-create of a specified existing note, update the current existing note or create a useful initial note when absent; for a broad artifact, use the hierarchy default unless the single-note override applies. Autonomous mode never creates empty notes or saves inappropriate sensitive content.
2882
+ EXTEND EXISTING HIERARCHIES: A request such as "Create Glass Dunes under Deserts" authorizes a child note and a navigation-link update to its parent. Resolve Deserts from the current conversation folder or conversation context, then search if needed. For one unambiguous branch overview at ".../Regions/Deserts/Deserts Overview.md", create ".../Regions/Deserts/Glass Dunes.md", then read the parent's latest content and add a full-path link with a conditional update. Multiple plausible Deserts matches require clarification. If the requested branch is missing, create its "<Subcategory>/<Subcategory> Overview.md" branch only when its intended parent is unambiguous; otherwise clarify. The same rule applies recursively beneath any category or leaf. Never automatically move or restructure existing notes.
2883
+
2884
+ AVOID DUPLICATE NOTES: Search by title and topic before every create. Within the established conversation folder, read and update an unambiguous match for the same artifact instead of creating another note. If the exact destination already exists, treat already_exists as a stop signal: read and reconcile the existing note when it is the same artifact, otherwise clarify. Never create "Copy", "Copy 2", numeric, random, or date variants to bypass a collision. Reuse or link to relevant existing vault knowledge without copying it into another conversation folder, and never merge two conversation folders.
2885
+
2886
+ For extend-or-create of a specified existing note, update the current existing note or create a useful initial note when absent; for a broad artifact, use the hierarchy default unless the single-note override applies. Autonomous mode never creates empty notes or saves inappropriate sensitive content.
2880
2887
 
2881
2888
  Obsidian displays the filename as its inline title. Create body content only: do not include frontmatter or repeat the note title as a leading H1. Use ## for section headings and supply tags through the create tool's tags field. Existing notes keep their own structure; read before updating and do not remove an existing title merely to normalize it.
2882
2889
 
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  export { E as EncyclopediaDocumentInput, a as EncyclopediaDocumentResult, b as EncyclopediaSearchHit, c as EncyclopediaSearchInput } from '../encyclopedia-search.model-oFW8_rUT.js';
3
- import { F as FormatZodShapeOptions } from '../format-zod-shape.types-wf6Pwdvx.js';
4
- export { A as ALL_TOOL_NAMES, a as AUTONOMOUS_OBSIDIAN_TOOL_NAMES, D as DEFAULT_VARIANT_ID, E as ENCYCLOPEDIA_TOOL_NAMES, b as IMAGE_TASK_TEMPLATES, c as ImageTaskTemplate, I as IntentResult, d as IntentSchema, M as MEMORY_TOOL_NAMES, O as OBSIDIAN_TOOL_NAMES, e as ObsidianToolName, f as TOOL_DESCRIPTIONS, g as TOOL_NAMES, T as TemplateName, h as ToolName, i as VARIANT_NAMES, V as VariantName, j as isImageTaskTemplate } from '../format-zod-shape.types-wf6Pwdvx.js';
3
+ import { F as FormatZodShapeOptions } from '../format-zod-shape.types-DbOhrGEO.js';
4
+ export { A as ALL_TOOL_NAMES, a as AUTONOMOUS_OBSIDIAN_TOOL_NAMES, D as DEFAULT_VARIANT_ID, E as ENCYCLOPEDIA_TOOL_NAMES, b as IMAGE_TASK_TEMPLATES, c as ImageTaskTemplate, I as IntentResult, d as IntentSchema, M as MEMORY_TOOL_NAMES, O as OBSIDIAN_TOOL_NAMES, e as ObsidianToolName, f as TOOL_DESCRIPTIONS, g as TOOL_NAMES, T as TemplateName, h as ToolName, i as VARIANT_NAMES, V as VariantName, j as isImageTaskTemplate } from '../format-zod-shape.types-DbOhrGEO.js';
5
5
 
6
6
  declare const BLOCKED_IMAGE_HOSTS: Set<string>;
7
7
 
@@ -489,6 +489,7 @@ declare const obsidianCreateNoteSchema: z.ZodObject<{
489
489
  title: z.ZodString;
490
490
  content: z.ZodString;
491
491
  folder: z.ZodOptional<z.ZodString>;
492
+ conversationRoot: z.ZodOptional<z.ZodBoolean>;
492
493
  tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
493
494
  }, z.core.$strip>;
494
495
  type ObsidianCreateNoteInput = z.infer<typeof obsidianCreateNoteSchema>;
@@ -1183,7 +1183,10 @@ var obsidianCreateNoteSchema = z.object({
1183
1183
  "Clean Markdown body without frontmatter or a repeated title H1; use ## for sections. Parent notes may contain a concise overview and full-path Wikilinks to children without duplicating their content. Empty is allowed only for an explicitly requested blank starting page."
1184
1184
  ),
1185
1185
  folder: z.string().trim().max(512).optional().describe(
1186
- "Optional vault-relative folder for this note, including nested hierarchy paths such as tripleF/My Game/Regions/Deserts; defaults to the configured autonomous-note folder."
1186
+ "Optional vault-relative folder for this note, including nested hierarchy paths such as tripleF/My Game - conversation-id/Regions/Deserts. A note basename must differ from every destination folder segment; defaults to the configured autonomous-note folder."
1187
+ ),
1188
+ conversationRoot: z.boolean().optional().describe(
1189
+ "Set true only when creating the first <Topic> Overview.md inside a newly established <Topic> - <conversationId> folder. Omit for every other note and for explicit single-note creates at user-supplied destinations."
1187
1190
  ),
1188
1191
  tags: z.array(z.string().trim().min(1).max(64)).max(20).optional().describe("Optional frontmatter tags.")
1189
1192
  });
@@ -1194,6 +1197,13 @@ function createObsidianClient(deps) {
1194
1197
  }
1195
1198
  return new ObsidianClient(config);
1196
1199
  }
1200
+
1201
+ // src/tools/obsidian/resolve-obsidian-root-conversation-folder.helper.ts
1202
+ function resolveObsidianRootConversationFolder(path, conversationRoot) {
1203
+ if (conversationRoot !== true) return void 0;
1204
+ const separator = path.lastIndexOf("/");
1205
+ return separator > 0 ? path.slice(0, separator) : void 0;
1206
+ }
1197
1207
  function toObsidianErrorResult(error, path) {
1198
1208
  const normalized = ObsidianClientError.from(error, path);
1199
1209
  return {
@@ -1208,14 +1218,19 @@ function toObsidianErrorResult(error, path) {
1208
1218
  // src/tools/obsidian/create-note.tool.ts
1209
1219
  function createObsidianCreateNoteTool(deps) {
1210
1220
  return tool({
1211
- description: "Create one clean, curated Obsidian Markdown note without overwriting an existing path. For a multi-part artifact, call this once per note with its exact nested hierarchy folder. Use the configured default folder for the root unless the user specified another destination.",
1221
+ description: "Create one clean, curated Obsidian Markdown note without overwriting an existing path. Search by title and topic first and never create numeric, copy, random, or date-suffixed duplicates. For a new conversation artifact, first create its <Topic> Overview.md inside <Topic> - <conversationId> with conversationRoot true. For subsequent notes, use the established conversation folder and omit conversationRoot. A note basename must differ from every destination folder segment.",
1212
1222
  inputSchema: obsidianCreateNoteSchema,
1213
1223
  execute: async (input, options) => {
1214
1224
  try {
1215
1225
  deps.logger.log(`Obsidian create ${input.title}`);
1216
- return await createObsidianClient(deps).create(input, options.abortSignal);
1226
+ const { conversationRoot, ...note } = input;
1227
+ const result = await createObsidianClient(deps).create(note, options.abortSignal);
1228
+ const conversationFolder = resolveObsidianRootConversationFolder(result.path, conversationRoot);
1229
+ return conversationFolder ? { ...result, conversationFolder } : result;
1217
1230
  } catch (error) {
1218
- return toObsidianErrorResult(error);
1231
+ const result = toObsidianErrorResult(error);
1232
+ const conversationFolder = result.path ? resolveObsidianRootConversationFolder(result.path, input.conversationRoot) : void 0;
1233
+ return result.code === "already_exists" && conversationFolder ? { ...result, conversationFolder } : result;
1219
1234
  }
1220
1235
  }
1221
1236
  });
@@ -1291,7 +1306,7 @@ var obsidianSearchNotesSchema = z.object({
1291
1306
  });
1292
1307
  function createObsidianSearchNotesTool(deps) {
1293
1308
  return tool({
1294
- description: "Search the connected Obsidian vault for Markdown notes. Returns bounded paths, scores, and snippets; read a selected note for its full current content.",
1309
+ description: "Search the connected Obsidian vault for Markdown notes before creating or updating. Returns bounded paths, scores, and snippets; read a selected note for its full current content. Before every create, search by title and topic and reuse an unambiguous match for the same artifact instead of creating a duplicate.",
1295
1310
  inputSchema: obsidianSearchNotesSchema,
1296
1311
  execute: async (input, options) => {
1297
1312
  try {
package/package.json CHANGED
@@ -1,8 +1,7 @@
1
1
  {
2
2
  "name": "@triplef/agent",
3
3
  "description": "tripleF (3F) agent domain — structured-output schemas, prompt builders, and model tools shared across the apps.",
4
- "version": "3.0.0",
5
- "packageManager": "pnpm@12.26.0",
4
+ "version": "3.1.0",
6
5
  "license": "SEE LICENSE IN LICENSE",
7
6
  "type": "module",
8
7
  "exports": {
@@ -20,11 +20,11 @@ type ImageTaskTemplate = (typeof IMAGE_TASK_TEMPLATES)[number];
20
20
  declare function isImageTaskTemplate(template: string): template is ImageTaskTemplate;
21
21
  declare const IntentSchema: z.ZodObject<{
22
22
  template: z.ZodEnum<{
23
+ article: "article";
24
+ news: "news";
23
25
  describe: "describe";
24
26
  compare: "compare";
25
27
  ocr: "ocr";
26
- article: "article";
27
- news: "news";
28
28
  summary: "summary";
29
29
  evaluation: "evaluation";
30
30
  product: "product";