-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcoding-agent.ts
More file actions
90 lines (84 loc) · 2.48 KB
/
Copy pathcoding-agent.ts
File metadata and controls
90 lines (84 loc) · 2.48 KB
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
import type { MarkdownArtifactBundle } from "goodmemory";
import {
createGoodMemory,
createInMemoryDocumentStore,
createInMemorySessionStore,
createRuntimeArchiveStore,
createRuntimeContextService,
} from "goodmemory";
export async function runCodingAgentExample(): Promise<{
artifacts: MarkdownArtifactBundle;
memoryContext: string;
answer: string;
}> {
const documentStore = createInMemoryDocumentStore();
const sessionStore = createInMemorySessionStore();
const runtime = createRuntimeContextService({
sessionStore,
archiveStore: createRuntimeArchiveStore({ documentStore }),
now: () => "2026-04-02T00:00:00.000Z",
maxBufferedMessages: 2,
});
const memory = createGoodMemory({
storage: { provider: "memory" },
adapters: {
documentStore,
sessionStore,
},
});
const scope = {
userId: "agent-user",
sessionId: "agent-s1",
workspaceId: "example-agent",
} as const;
await runtime.startSession(scope);
await runtime.appendToSession(scope, {
role: "user",
content: "Outline the rollback checklist before deploy.",
});
await runtime.appendToSession(scope, {
role: "assistant",
content: "Use the rollback checklist before deploy.",
});
await runtime.updateWorkingMemory(scope, {
currentGoal: "Finish recall engine",
openLoops: ["wire buildContext output"],
temporaryDecisions: ["Use the rollback checklist before deploy."],
});
await runtime.updateSessionJournal(scope, {
currentState: "Phase 6 in progress",
appendWorklog: ["Recall router implemented."],
});
await runtime.appendToSession(scope, {
role: "user",
content: "Continue the recall engine implementation.",
});
await memory.feedback({
scope,
signal: "Please keep coding task updates concise and action-oriented.",
});
const recall = await memory.recall({
scope,
query: "Continue the coding task from last time.",
retrievalProfile: "coding_agent",
});
const context = await memory.buildContext({
recall,
output: "markdown",
maxTokens: 200,
});
const exported = await memory.exportMemory({
scope,
includeRuntime: true,
});
return {
artifacts: exported.artifacts,
memoryContext: context.content,
answer:
"Next step: Finish recall engine, then wire buildContext output before closing the open loop on wire buildContext output.",
};
}
if (import.meta.main) {
const result = await runCodingAgentExample();
console.log(JSON.stringify(result, null, 2));
}