{"version":3,"file":"memory-write.d.ts","sourceRoot":"","sources":["../../../src/core/tools/memory-write.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,KAAK,MAAM,EAAQ,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,QAAA,MAAM,iBAAiB;;;;EAMrB,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAEhE,MAAM,WAAW,qBAAqB;IACrC,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,UAAU,EAAE,CAAC;IAClD,KAAK,EAAE,MAAM,UAAU,EAAE,CAAC;CAC1B;AAED,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,qBAAqB,GAAG,SAAS,CAAC,OAAO,iBAAiB,CAAC,CAsC5G;AAED,eAAO,MAAM,eAAe,EAAE,SAAS,CAAC,OAAO,iBAAiB,CAG9D,CAAC","sourcesContent":["import type { AgentTool } from \"@apholdings/jensen-agent-core\";\nimport { type Static, Type } from \"@sinclair/typebox\";\nimport type { MemoryItem } from \"../memory.js\";\n\nconst memoryWriteSchema = Type.Object({\n\taction: Type.Union([Type.Literal(\"set\"), Type.Literal(\"clear\")], {\n\t\tdescription: \"Whether to set a memory item or clear all session memory\",\n\t}),\n\tkey: Type.Optional(Type.String({ description: \"Memory key, such as constraints.test_command\" })),\n\tvalue: Type.Optional(Type.String({ description: \"Memory value to retain across compaction\" })),\n});\n\nexport type MemoryWriteInput = Static<typeof memoryWriteSchema>;\n\nexport interface MemoryWriteOperations {\n\tset: (key: string, value: string) => MemoryItem[];\n\tclear: () => MemoryItem[];\n}\n\nexport function createMemoryWriteTool(operations: MemoryWriteOperations): AgentTool<typeof memoryWriteSchema> {\n\treturn {\n\t\tname: \"memory_write\",\n\t\tlabel: \"memory_write\",\n\t\tdescription:\n\t\t\t\"Record or clear structured session memory that should survive compaction. Use for stable facts, constraints, and decisions that matter on future turns.\",\n\t\tparameters: memoryWriteSchema,\n\t\texecute: async (_toolCallId: string, input: MemoryWriteInput) => {\n\t\t\tif (input.action === \"clear\") {\n\t\t\t\tconst items = operations.clear();\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: `Cleared session memory (${items.length} items remain)` }],\n\t\t\t\t\tdetails: { items },\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst key = input.key?.trim();\n\t\t\tconst value = input.value?.trim();\n\t\t\tif (!key) {\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: \"Error: key is required when action=set\" }],\n\t\t\t\t\tdetails: undefined,\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (!value) {\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: \"Error: value is required when action=set\" }],\n\t\t\t\t\tdetails: undefined,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst items = operations.set(key, value);\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: `Stored memory: ${key}` }],\n\t\t\t\tdetails: { items },\n\t\t\t};\n\t\t},\n\t};\n}\n\nexport const memoryWriteTool: AgentTool<typeof memoryWriteSchema> = createMemoryWriteTool({\n\tset: () => [],\n\tclear: () => [],\n});\n"]}