@agenr/openclaw-plugin 0.14.1 → 1.2.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.
package/dist/index.d.ts DELETED
@@ -1,338 +0,0 @@
1
- import { Model, Api, Context, SimpleStreamOptions, AssistantMessageEvent, AssistantMessage } from '@mariozechner/pi-ai';
2
- import * as _sinclair_typebox from '@sinclair/typebox';
3
-
4
- /**
5
- * Handoff transcript helpers - reading, parsing, building, and formatting
6
- * transcript content for session handoff summaries.
7
- */
8
- type HandoffMessage = {
9
- role: "user" | "assistant";
10
- content: string;
11
- timestamp: string;
12
- };
13
- declare function getBaseSessionPath(filePath: string): string;
14
- declare function readSessionsJson(sessionsDir: string): Promise<Record<string, unknown>>;
15
- declare function readAndParseSessionJsonl(sessionFile: string): Promise<unknown[]>;
16
- declare function getSurfaceForSessionFile(sessionFilePath: string, sessionsJson: Record<string, unknown>, sessionsDir?: string): string;
17
- declare function readMessagesFromJsonl(filePath: string): Promise<HandoffMessage[]>;
18
- declare function findPriorResetFile(sessionsDir: string, currentSessionFile: string): Promise<string | null>;
19
- declare function buildTranscript(messages: HandoffMessage[], surface: string): string;
20
- declare function buildMergedTranscript(priorMessages: HandoffMessage[], priorSurface: string, currentMessages: HandoffMessage[], currentSurface: string): string;
21
- declare function capTranscriptLength(params: {
22
- priorMessages: HandoffMessage[];
23
- priorSurface: string;
24
- currentMessages: HandoffMessage[];
25
- currentSurface: string;
26
- maxChars: number;
27
- }): string;
28
-
29
- type RecallIntentFamily = "generic" | "invariant_lookup" | "prerequisite_step" | "policy_bundle_lookup";
30
- /**
31
- * Stable, product-level semantics for the bounded recall decision layer.
32
- * Keep lexical hits, thresholds, and other heuristic internals in trace data.
33
- */
34
- type RecallReasonCode = "sufficient_direct_support" | "sufficient_composite_support" | "subject_mismatch" | "no_answer_bearing_support" | "ambiguous_competing_support" | "support_set_too_diffuse" | "support_below_confidence_floor";
35
- type RecallSupportMode = "single" | "pair" | "continuity_bundle";
36
- /**
37
- * Additive recall payload emitted only when the bounded MVP layer is allowed to
38
- * intervene. Absence means generic retrieval fallback, not an implicit abstain.
39
- *
40
- * In this MVP, `abstain` means the supported-intent post-retrieval pass found
41
- * no single-support winner above its confidence and ambiguity guardrails.
42
- */
43
- interface RecallDecision {
44
- decision: "answer" | "abstain";
45
- intent: RecallIntentFamily;
46
- reasonCodes: RecallReasonCode[];
47
- supportMode?: RecallSupportMode;
48
- supportIds: string[];
49
- surfacedIds: string[];
50
- competingIds: string[];
51
- }
52
- interface RecallCategoryRollupFacetSummary {
53
- facet: string;
54
- label: string;
55
- summary: string;
56
- evidence_ids: string[];
57
- evidence_subjects: string[];
58
- }
59
- interface RecallCategoryRollupSummary {
60
- mode: "category_rollup";
61
- path: "category_rollup_synthesis_v1";
62
- style: "broad_synthesis" | "project_story";
63
- kind: "family" | "personal_life" | "work" | "project";
64
- target: string;
65
- subject?: string;
66
- narrative: string;
67
- coverage: "broad" | "partial" | "sparse";
68
- evidence_ids: string[];
69
- evidence_subjects: string[];
70
- evidence_count: number;
71
- covered_facets: string[];
72
- facet_summaries: RecallCategoryRollupFacetSummary[];
73
- low_coverage_note?: string;
74
- project_rollup?: {
75
- kind: "project_history_v1";
76
- project_subject: string;
77
- prioritized_facets: Array<"project_scope" | "architecture" | "implementation" | "validation" | "follow_up">;
78
- section_order: string[];
79
- };
80
- }
81
-
82
- type SimpleAssistantStream = AsyncIterable<AssistantMessageEvent> & {
83
- result: () => Promise<AssistantMessage>;
84
- };
85
- type StreamSimpleFn = (model: Model<Api>, context: Context, options?: SimpleStreamOptions) => SimpleAssistantStream;
86
-
87
- declare const OPENCLAW_MEMORY_RELIABILITY_DIAGNOSTIC_SCHEMA_VERSION: "openclaw-memory-reliability-diagnostic-v1";
88
- type DiagnosticSessionProjectState = "set" | "cleared" | "unset" | "not-applicable";
89
- type DiagnosticWriteAttributionSurface = "native-store" | "watcher" | "handoff" | "openclaw-bridge-store";
90
- type DiagnosticWriteAttributionSource = "tool-project" | "session-project" | "plugin-default" | "watcher-fallback" | "entry-project" | "shared-attribution" | "bridge-fallback" | "none";
91
- type DiagnosticWriteAttributionReason = "explicit-tool-project" | "explicit-session-project" | "explicit-session-cleared" | "session-project-not-worthy" | "plugin-default-project" | "watcher-inferred-project" | "existing-entry-project" | "shared-project-attribution" | "bridge-fallback-project" | "no-project-candidate";
92
- type DiagnosticWriteAttributionKind = "explicit" | "inferred" | "default" | "shared" | "fallback" | "global";
93
- interface WriteAttributionResolutionDiagnostic {
94
- kind: "openclaw-memory-reliability-diagnostic";
95
- schemaVersion: typeof OPENCLAW_MEMORY_RELIABILITY_DIAGNOSTIC_SCHEMA_VERSION;
96
- decisionClass: "write-attribution-resolution";
97
- ownerSubsystem: "write-attribution";
98
- laneHint: "cross-surface-scope-attribution";
99
- surface: DiagnosticWriteAttributionSurface;
100
- inputs: {
101
- explicitProjectProvided: boolean;
102
- sessionProjectState: DiagnosticSessionProjectState;
103
- defaultProjectPresent: boolean;
104
- fallbackProjectPresent: boolean;
105
- entryProjectPresent: boolean;
106
- upstreamAttributionPresent: boolean;
107
- };
108
- outcome: {
109
- project: string | null;
110
- source: DiagnosticWriteAttributionSource;
111
- reason: DiagnosticWriteAttributionReason;
112
- attributionKind: DiagnosticWriteAttributionKind;
113
- sessionProjectGate: "batch" | "entry" | "not-applicable";
114
- };
115
- }
116
- type DiagnosticSurfacedMemorySurface = "session-start" | "mid-session-recall" | "agent-tool-recall";
117
- type DiagnosticSurfacedMemoryStage = "browse-admitted" | "selector-shaped" | "render-input" | "retrieved" | "prompt-visible" | "nudge-candidates";
118
- type DiagnosticSurfacedMemorySource = "plugin-injection" | "agent-tool-output";
119
- type DiagnosticSurfacedMemoryOwnershipClass = "startup-pre-prompt-candidate" | "startup-render-input-candidate" | "startup-prompt-visible-before-reset-owned" | "mid-session-retrieved-candidate" | "mid-session-prompt-visible-dedupe-only" | "mid-session-nudge-candidate" | "agent-tool-prompt-visible-dedupe-only";
120
- type DiagnosticSurfacedMemoryReason = "startup-pre-prompt-stage" | "startup-render-input-stage" | "startup-prompt-visible-stage" | "mid-session-retrieved-stage" | "mid-session-prompt-visible-stage" | "mid-session-nudge-stage" | "agent-tool-prompt-visible-stage";
121
- interface SurfacedMemoryOwnershipDiagnostic {
122
- kind: "openclaw-memory-reliability-diagnostic";
123
- schemaVersion: typeof OPENCLAW_MEMORY_RELIABILITY_DIAGNOSTIC_SCHEMA_VERSION;
124
- decisionClass: "surfaced-memory-ownership-classification";
125
- ownerSubsystem: "surfaced-memory-contract";
126
- laneHint: "user-facing-surfacing";
127
- surface: DiagnosticSurfacedMemorySurface;
128
- stage: DiagnosticSurfacedMemoryStage;
129
- source?: DiagnosticSurfacedMemorySource;
130
- ownershipClass: DiagnosticSurfacedMemoryOwnershipClass;
131
- reason: DiagnosticSurfacedMemoryReason;
132
- outcome: {
133
- promptVisible: boolean;
134
- dedupeEligible: boolean;
135
- beforeResetOwned: boolean;
136
- handoffConsumptionEligible: boolean;
137
- };
138
- }
139
-
140
- interface RecallSurfaceSelection {
141
- authoritative: boolean;
142
- abstained: boolean;
143
- surfacedIds: string[];
144
- }
145
-
146
- type RecallEntry = {
147
- type: string;
148
- subject: string;
149
- content: string;
150
- importance?: number;
151
- };
152
- type RecallResult = {
153
- query: string;
154
- decision?: RecallDecision;
155
- rollupSummary?: RecallCategoryRollupSummary;
156
- surfaceSelection?: RecallSurfaceSelection;
157
- results: Array<{
158
- entry: RecallEntry & Record<string, unknown>;
159
- score: number;
160
- category?: string;
161
- }>;
162
- };
163
- type RecallResultItems = RecallResult["results"];
164
-
165
- type MidSessionMemoryItems = RecallResultItems;
166
- interface PromptVisibleAgentToolRecallMemory {
167
- surface: "agent-tool-recall";
168
- stage: "prompt-visible";
169
- visibility: "prompt-visible";
170
- source: "agent-tool-output";
171
- query: string;
172
- items: MidSessionMemoryItems;
173
- memoryReliabilityDiagnostic?: SurfacedMemoryOwnershipDiagnostic;
174
- }
175
- interface PromptVisibleAgentToolRecallMemoryBookkeeping {
176
- surface: "agent-tool-recall";
177
- stage: "prompt-visible";
178
- visibility: "prompt-visible";
179
- source: PromptVisibleAgentToolRecallMemory["source"];
180
- surfacedEntryIds: string[];
181
- beforeResetOwnedEntryIds: string[];
182
- memoryReliabilityDiagnostic?: SurfacedMemoryOwnershipDiagnostic;
183
- }
184
-
185
- type BeforeAgentStartEvent = {
186
- prompt?: string;
187
- messages?: unknown[];
188
- [key: string]: unknown;
189
- };
190
- type PluginHookAgentContext = {
191
- sessionKey?: string;
192
- sessionId?: string;
193
- agentId?: string;
194
- workspaceDir?: string;
195
- [key: string]: unknown;
196
- };
197
- type BeforeAgentStartResult = {
198
- prependContext?: string;
199
- };
200
- type BeforePromptBuildEvent = {
201
- prompt?: string;
202
- messages?: unknown[];
203
- [key: string]: unknown;
204
- };
205
- type BeforePromptBuildResult = {
206
- systemPrompt?: string;
207
- prependContext?: string;
208
- prependSystemContext?: string;
209
- };
210
- type BeforeResetEvent = {
211
- sessionFile?: string;
212
- messages?: unknown[];
213
- reason?: string;
214
- [key: string]: unknown;
215
- };
216
- type PluginLogger = {
217
- debug?: (message: string) => void;
218
- info?: (message: string) => void;
219
- warn: (message: string) => void;
220
- error: (message: string) => void;
221
- };
222
- type PluginToolResult = {
223
- content: Array<{
224
- type: "text";
225
- text: string;
226
- }>;
227
- details?: Record<string, unknown>;
228
- agentToolRecallSurface?: PromptVisibleAgentToolRecallMemoryBookkeeping;
229
- };
230
- type PluginTool = {
231
- name: string;
232
- label?: string;
233
- description: string;
234
- parameters: _sinclair_typebox.TObject;
235
- execute: (toolCallId: string, params: Record<string, unknown>) => Promise<PluginToolResult>;
236
- };
237
- type PluginToolOptions = {
238
- name?: string;
239
- names?: string[];
240
- optional?: boolean;
241
- };
242
- type InternalHookEvent = {
243
- type: "command" | "session" | "agent" | "gateway" | "message";
244
- action: string;
245
- sessionKey: string;
246
- context: Record<string, unknown>;
247
- timestamp: Date;
248
- messages: string[];
249
- };
250
- type InternalHookHandler = (event: InternalHookEvent) => Promise<void> | void;
251
- type PluginHookOptions = {
252
- priority?: number;
253
- entry?: unknown;
254
- name?: string;
255
- description?: string;
256
- register?: boolean;
257
- };
258
- type PluginApi = {
259
- id: string;
260
- name: string;
261
- version?: string;
262
- pluginConfig?: Record<string, unknown>;
263
- logger: PluginLogger;
264
- registerTool?: (tool: PluginTool, opts?: PluginToolOptions) => void;
265
- registerHook?: (events: string | string[], handler: InternalHookHandler, opts?: PluginHookOptions) => void;
266
- on: {
267
- (hook: "before_agent_start", handler: (event: BeforeAgentStartEvent, ctx: PluginHookAgentContext) => Promise<BeforeAgentStartResult | undefined> | BeforeAgentStartResult | undefined): void;
268
- (hook: "before_prompt_build", handler: (event: BeforePromptBuildEvent, ctx: PluginHookAgentContext) => Promise<BeforePromptBuildResult | undefined> | BeforePromptBuildResult | undefined): void;
269
- (hook: "before_reset", handler: (event: BeforeResetEvent, ctx: PluginHookAgentContext) => Promise<void> | void): void;
270
- };
271
- };
272
-
273
- type OpenClawWriteAttributionSurface = "native-store" | "watcher" | "handoff";
274
- type OpenClawWriteAttributionSource = "tool-project" | "session-project" | "plugin-default" | "watcher-fallback" | "entry-project" | "none";
275
- type OpenClawWriteAttributionReason = "explicit-tool-project" | "explicit-session-project" | "explicit-session-cleared" | "session-project-not-worthy" | "plugin-default-project" | "watcher-inferred-project" | "existing-entry-project" | "no-project-candidate";
276
- type OpenClawWriteAttributionKind = "explicit" | "inferred" | "default" | "global";
277
- type OpenClawWriteAttributionResolution = {
278
- surface: OpenClawWriteAttributionSurface;
279
- project: string | null;
280
- source: OpenClawWriteAttributionSource;
281
- reason: OpenClawWriteAttributionReason;
282
- attributionKind: OpenClawWriteAttributionKind;
283
- sessionProjectGate: "batch" | "entry" | "not-applicable";
284
- strictnessRelevant: false;
285
- dependencyExpansionRelevant: false;
286
- memoryReliabilityDiagnostic?: WriteAttributionResolutionDiagnostic;
287
- };
288
-
289
- declare function summarizeSessionForHandoff(currentRawMessages: BeforeResetEvent["messages"], sessionsDir: string, currentSessionFile: string, logger: PluginApi["logger"], includeBackground: boolean, streamSimpleImpl?: StreamSimpleFn, logEnabled?: boolean, logDir?: string, debugEnabled?: boolean): Promise<string | null>;
290
- interface RunHandoffForSessionOptions {
291
- messages: unknown[];
292
- sessionFile: string | null;
293
- sessionId: string;
294
- sessionKey: string;
295
- agentId: string;
296
- budget: number;
297
- defaultProject: string | undefined;
298
- projectAttribution?: OpenClawWriteAttributionResolution;
299
- storeConfig: Record<string, unknown>;
300
- sessionsDir: string;
301
- includeBackground?: boolean;
302
- logEnabled?: boolean;
303
- logDir?: string;
304
- debugEnabled?: boolean;
305
- logger: PluginLogger | undefined;
306
- source: "before_reset" | "command" | "session_start";
307
- dbPath?: string;
308
- summarizeSessionForHandoffImpl?: typeof summarizeSessionForHandoff;
309
- }
310
-
311
- declare function stripInjectedContext(text: string): string;
312
-
313
- type RunHandoffForSessionArgs = Omit<RunHandoffForSessionOptions, "summarizeSessionForHandoffImpl">;
314
- declare const plugin: {
315
- id: string;
316
- name: string;
317
- description: string;
318
- register(api: PluginApi): void;
319
- };
320
- declare const __testing: {
321
- clearState(): void;
322
- readSessionsJson: typeof readSessionsJson;
323
- readAndParseSessionJsonl: typeof readAndParseSessionJsonl;
324
- getBaseSessionPath: typeof getBaseSessionPath;
325
- getSurfaceForSessionFile: typeof getSurfaceForSessionFile;
326
- readMessagesFromJsonl: typeof readMessagesFromJsonl;
327
- stripInjectedContext: typeof stripInjectedContext;
328
- findPriorResetFile: typeof findPriorResetFile;
329
- buildTranscript: typeof buildTranscript;
330
- buildMergedTranscript: typeof buildMergedTranscript;
331
- capTranscriptLength: typeof capTranscriptLength;
332
- HANDOFF_SUMMARY_SYSTEM_PROMPT: string;
333
- HANDOFF_SUMMARY_SYSTEM_PROMPT_WITH_BACKGROUND: string;
334
- summarizeSessionForHandoff: typeof summarizeSessionForHandoff;
335
- runHandoffForSession(opts: RunHandoffForSessionArgs): Promise<void>;
336
- };
337
-
338
- export { __testing, plugin as default };
package/skills/SKILL.md DELETED
@@ -1,77 +0,0 @@
1
- ---
2
- name: agenr
3
- description: Use when storing new knowledge (decisions, preferences, lessons, todos) or recalling context mid-session. The agenr plugin auto-injects memory at session start - this skill covers proactive store and on-demand recall.
4
- ---
5
-
6
- ## agenr_store
7
-
8
- Use proactively for durable knowledge - decisions, preferences, lessons, and facts that future sessions need to make better decisions.
9
-
10
- **The future-session test:** Before storing, ask: "If I woke up in a fresh session and recalled this, would it change how I act?" If the answer is just "it tells me something that already happened and is done" - do not store it.
11
-
12
- **Store:**
13
- - Architecture decisions and design rationale
14
- - Workflow constraints and operational rules
15
- - Lessons learned from problems (recurring bugs, what worked, what did not)
16
- - User preferences and working-style observations
17
- - Durable facts about systems, environments, people, projects
18
- - Important open risks or unresolved hazards
19
-
20
- **Do not store:**
21
- - Version or release shipping events ("v1.2.3 shipped") - changelogs are the system of record
22
- - Issue or PR filing records ("filed #123, #124") - the issue tracker is the system of record
23
- - Phase plans or release packaging decisions - transient coordination artifacts, stale within a session
24
- - Progress snapshots ("3 of 5 tasks done") - stale within minutes
25
- - Prompt file paths or internal build logistics - look-up-able, not memory-worthy
26
- - Anything whose only value is duplicating files, the issue tracker, or git history
27
-
28
- Do not ask before storing - but do ask whether future-you needs it.
29
-
30
- Required: `type`, `content`, `importance`.
31
- Optional: `subject` (short label), `tags` (array), `scope` (`private`|`personal`|`public`), `project`, `platform`, `source`.
32
-
33
- Types: `fact | decision | preference | todo | lesson | event | relationship`
34
- Do not store secrets/credentials, temporary state, or verbatim conversation.
35
-
36
- ### Importance calibration
37
-
38
- - **10**: Once-per-project permanent constraints. At most 1-2 per project lifetime.
39
- - **9**: Critical breaking changes or immediate cross-session decisions. At most 1 per significant session, often 0.
40
- - **8**: Things an active parallel session would act on right now. Fires a cross-session signal. Use conservatively.
41
- - **7**: Default. Project facts, decisions, preferences, milestones. No signal fired.
42
- - **6**: Routine dev observations (verified X, tests passing). Cap here unless the result is surprising.
43
- - **5**: Borderline. Only store if clearly durable beyond today.
44
- - **Importance is not recency.** Something that just happened is not automatically important. A shipping event is importance 5-6 at best unless it teaches a lesson. A recurring operational hazard is importance 7-8 because it affects future decisions.
45
-
46
- Entries at 7 are saved silently. Use 8+ only if other active sessions need to know NOW.
47
-
48
- ### Confidence-aware extraction (OpenClaw transcripts)
49
-
50
- OpenClaw transcripts include `[user]` / `[assistant]` role labels. The extractor uses this signal:
51
- - Hedged or unverified assistant factual claims are tagged `unverified` and hard-capped at importance 5.
52
- - Tool-verified assistant claims follow normal importance rules.
53
- - User messages are never capped.
54
-
55
- This means: if you say something unverified, it will be stored at max importance 5. To store a fact at higher importance, verify it with a tool call first.
56
-
57
- ## agenr_recall
58
-
59
- Use mid-session when you need context you don't already have. Session-start recall is handled automatically - do not call at turn 1 unless you need extra context beyond the injected summary.
60
-
61
- Parameters:
62
- - `query` (required): semantic search string
63
- - `limit`: max results (default 10)
64
- - `context`: `"default"` (semantic+vector) or `"session-start"` (fast bootstrap)
65
- - `since`: lower date bound - only entries newer than this (ISO or relative, e.g. `"7d"`, `"2026-01-01"`)
66
- - `until`: upper date bound - only entries older than this ceiling (e.g. `"7d"` = entries created before 7 days ago). Use with `since` for a date window.
67
- - `types`: comma-separated entry types (`fact,decision,preference,todo,lesson,event`)
68
- - `platform`: filter by platform (`openclaw`, `claude-code`, `codex`)
69
- - `project`: filter by project scope (pass `*` for all projects)
70
-
71
- ## agenr_retire
72
-
73
- Soft-deletes an entry. Use when something is outdated, wrong, or superseded. Pass `entry_id` (from recall results) and optionally `reason` and `persist: true` to write to the retirements ledger.
74
-
75
- ## agenr_extract
76
-
77
- Extracts structured knowledge entries from raw text without storing them. Useful for previewing what would be stored from a block of text before committing.