An open-source, faster Devin alternative
TypeScript
docs: declare then read with the definition; multi-user guidance; drop the default environment flag
Igor Zalutski4a3331366aa6
diff --git a/docs/agents/document-memory.mdx b/docs/agents/document-memory.mdxindex 346279cb..a52a5231 100644--- a/docs/agents/document-memory.mdx+++ b/docs/agents/document-memory.mdx@@ -70,6 +70,10 @@ Set `memory.<resource>` when creating a session:- Resources must be declared by the deployment and bound documents must exist.Invalid bindings fail admission.- Bindings stay fixed. Schedules, channels and webhooks do not configure them.+- One store per project and environment. An application with many users+ keeps their data apart with document bindings and application-chosen+ document IDs; a collection binding sees every document of the resource, so+ it suits a single owner or a coordinating agent, not one user among many.Calling `useMemory` exposes the binding's tools; omitting it exposes none.An unbound hook fails before inference. Tools accept a `memory` resource ID,@@ -204,35 +208,31 @@ Install the CLI, then [log in and link your project](/agents/quickstart):npm install -g @opencomputer/cli```-Commands below use Development; change `--environment` to `production` as-needed.+Commands default to Development; add `--environment production` for+production.List metadata:```bash-opencomputer memory list notes \- --environment development+opencomputer memory list notes```Read a document:```bash-opencomputer memory show notes workshop \- --environment development+opencomputer memory show notes workshop```Create empty notes:```bash-opencomputer memory create notes workshop \- --title "Workshop" --environment development+opencomputer memory create notes workshop --title "Workshop"```Open existing text in your editor:```bash-opencomputer memory edit notes workshop \- --environment development+opencomputer memory edit notes workshop```Create and edit accept `--text-file <path>`, `--text-stdin`, and@@ -245,15 +245,13 @@ returns the [document object](#documents).Freeze:```bash-opencomputer memory freeze notes workshop \- --environment development+opencomputer memory freeze notes workshop```Re-enable writes:```bash-opencomputer memory unfreeze notes workshop \- --environment development+opencomputer memory unfreeze notes workshop```Freeze sets `agentWrites: "disabled"`; after success, no later agent save can@@ -268,8 +266,7 @@ a separate completion contract.### Export saved notes```bash-opencomputer memory export --out ./memory \- --environment development+opencomputer memory export --out ./memory```Export includes retired resources; repeat `--resource <id>` to restrict it.@@ -280,8 +277,7 @@ Credentials, conversation history and sandbox files are excluded.### Delete a document```bash-opencomputer memory remove notes workshop \- --environment development+opencomputer memory remove notes workshop```Deletion removes title, text and summary but reserves the ID against delayeddiff --git a/docs/agents/memory.mdx b/docs/agents/memory.mdxindex 9fa0d069..1d1be995 100644--- a/docs/agents/memory.mdx+++ b/docs/agents/memory.mdx@@ -6,26 +6,9 @@ description: "Read and save notes across sessions"Memory stores requirements, decisions and preferences that later sessions canreuse. Owners can read, edit and export the same notes.-`useMemory` reads bound memory and selects its tools for the next model step:--```ts-import { useMemory } from "@opencomputer/agent";--export default function Agent() {- const memory = useMemory("notes");- return `Help plan the workshop.-Save changes with memory_save.-Keep other confirmed requirements.-Saved requirements: ${JSON.stringify(memory.text)}`;-}-```--The hook is synchronous. Your agent decides where to put `memory.text` in its-instructions; the hook does not insert it automatically.-## Declare a resource-Add the declaration at module scope in the same agent file:+A resource is declared once, at module scope, like a tool or a connection:```tsimport { defineMemory } from "@opencomputer/agent";@@ -43,6 +26,32 @@ before binding it to a session.`notes` is an application-defined resource name. It can contain many documents;this example calls one `workshop`. Neither name is built into OpenComputer.+Declare with a direct `defineMemory({...})` on a literal object; the compiler+rejects aliases, spreads and variables so that what it registers is exactly+what runs.++## Read it in the render++`useMemory` returns the bound text and selects the memory tools for the next+model step:++```ts+import { useMemory } from "@opencomputer/agent";+import { notes } from "./memory";++export default function Agent() {+ const memory = useMemory(notes);+ return `Help plan the workshop.+Save changes with memory_save and keep the other confirmed requirements.++## Confirmed requirements+${memory.text}`;+}+```++The hook is synchronous and returns `{ text, sources, writable }`. Your agent+decides where the text goes in its instructions; nothing is inserted for you.+Treat saved text as data the model reads, not as instructions it follows.## Bind a document to a session