Skip to content

Commit b5e9179

Browse files
authored
docs: deprecate legacy session file helpers (#97494)
* docs: deprecate legacy session file helpers * docs: update sdk deprecation budgets
1 parent d577cb2 commit b5e9179

5 files changed

Lines changed: 33 additions & 12 deletions

File tree

docs/plugins/sdk-runtime.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,9 @@ two-party event loops that do not go through the shared inbound reply runner.
131131
await api.runtime.agent.ensureAgentWorkspace(cfg);
132132

133133
// Run an embedded agent turn
134-
const agentDir = api.runtime.agent.resolveAgentDir(cfg);
135134
const result = await api.runtime.agent.runEmbeddedAgent({
136135
sessionId: "my-plugin:task-1",
137136
runId: crypto.randomUUID(),
138-
sessionFile: path.join(agentDir, "sessions", "my-plugin-task-1.jsonl"),
139137
workspaceDir: api.runtime.agent.resolveAgentWorkspaceDir(cfg),
140138
prompt: "Summarize the latest changes",
141139
timeoutMs: api.runtime.agent.resolveAgentTimeoutMs(cfg),
@@ -166,9 +164,9 @@ two-party event loops that do not go through the shared inbound reply runner.
166164

167165
Prefer `getSessionEntry(...)`, `listSessionEntries(...)`, `patchSessionEntry(...)`, or `upsertSessionEntry(...)` for session workflows. These helpers address sessions by agent/session identity so plugins do not depend on the legacy `sessions.json` storage shape. Use `preserveActivity: true` for metadata-only patches that should not refresh session activity, and `replaceEntry: true` only when the callback returns a complete entry and deleted fields must stay deleted.
168166

169-
For transcript reads and writes, import `openclaw/plugin-sdk/session-transcript-runtime` and use `resolveSessionTranscriptIdentity(...)`, `resolveSessionTranscriptTarget(...)`, `readSessionTranscriptEvents(...)`, `appendSessionTranscriptMessageByIdentity(...)`, `publishSessionTranscriptUpdateByIdentity(...)`, or `withSessionTranscriptWriteLock(...)` with `{ agentId, sessionKey, sessionId }`. These APIs let plugins identify a transcript, read its events, append messages, publish updates, and run related operations under the same transcript write lock. Pass `sessionFile` only when adapting code that already receives an active transcript artifact and needs each helper to operate on that same artifact.
167+
For transcript reads and writes, import `openclaw/plugin-sdk/session-transcript-runtime` and use `resolveSessionTranscriptIdentity(...)`, `resolveSessionTranscriptTarget(...)`, `readSessionTranscriptEvents(...)`, `appendSessionTranscriptMessageByIdentity(...)`, `publishSessionTranscriptUpdateByIdentity(...)`, or `withSessionTranscriptWriteLock(...)` with `{ agentId, sessionKey, sessionId }`. These APIs let plugins identify a transcript, read its events, append messages, publish updates, and run related operations under the same transcript write lock. Passing `sessionFile`, using `resolveSessionTranscriptLegacyFileTarget(...)`, or importing low-level `appendSessionTranscriptMessage(...)` / `emitSessionTranscriptUpdate(...)` from `openclaw/plugin-sdk/agent-harness-runtime` is deprecated; those paths exist only for legacy code that already receives an active transcript artifact.
170168

171-
`loadSessionStore(...)`, `saveSessionStore(...)`, `updateSessionStore(...)`, and `resolveSessionFilePath(...)` are compatibility helpers for plugins that still intentionally depend on the legacy whole-store or transcript-file shape. New plugin code must not use those helpers, and existing callers should migrate to entry helpers.
169+
`loadSessionStore(...)`, `saveSessionStore(...)`, `updateSessionStore(...)`, `resolveSessionFilePath(...)`, and `resolveAndPersistSessionFile(...)` are deprecated compatibility helpers for plugins that still intentionally depend on the legacy whole-store or transcript-file shape. New plugin code must not use those helpers, and existing callers should migrate to entry helpers and transcript identity helpers.
172170

173171
</Accordion>
174172
<Accordion title="api.runtime.agent.defaults">

scripts/plugin-sdk-surface-report.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ const defaultPublicDeprecatedExportsByEntrypointBudget = Object.freeze({
164164
"channel-policy": 8,
165165
"channel-route": 5,
166166
"session-store-runtime": 1,
167-
"session-transcript-runtime": 1,
167+
"session-transcript-runtime": 2,
168168
"group-access": 13,
169169
"media-generation-runtime-shared": 3,
170170
"music-generation-core": 20,
@@ -206,7 +206,7 @@ try {
206206
publicFunctionExports: readBudgetEnv("OPENCLAW_PLUGIN_SDK_MAX_PUBLIC_FUNCTION_EXPORTS", 5214),
207207
publicDeprecatedExports: readBudgetEnv(
208208
"OPENCLAW_PLUGIN_SDK_MAX_PUBLIC_DEPRECATED_EXPORTS",
209-
3247,
209+
3249,
210210
),
211211
publicWildcardReexports: readBudgetEnv(
212212
"OPENCLAW_PLUGIN_SDK_MAX_PUBLIC_WILDCARD_REEXPORTS",

src/plugin-sdk/agent-harness-runtime.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,17 @@ export {
286286
resolveSessionWriteLockOptions,
287287
type SessionWriteLockAcquireTimeoutConfig,
288288
} from "../agents/session-write-lock.js";
289+
/**
290+
* @deprecated Use appendSessionTranscriptMessageByIdentity from
291+
* openclaw/plugin-sdk/session-transcript-runtime so transcript writes target a
292+
* session identity instead of an active JSONL transcript file.
293+
*/
289294
export { appendSessionTranscriptMessage } from "../config/sessions/transcript-append.js";
295+
/**
296+
* @deprecated Use publishSessionTranscriptUpdateByIdentity from
297+
* openclaw/plugin-sdk/session-transcript-runtime so transcript updates target
298+
* a session identity instead of an active JSONL transcript file.
299+
*/
290300
export { emitSessionTranscriptUpdate } from "../sessions/transcript-events.js";
291301
export {
292302
consumeAdjustedParamsForToolCall,

src/plugin-sdk/config-runtime.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,18 @@ export type {
151151
export {
152152
clearSessionStoreCacheForTest,
153153
recordSessionMetaFromInbound,
154+
/**
155+
* @deprecated Use patchSessionEntry/upsertSessionEntry for writes. This
156+
* whole-store helper is kept only during the transition before SQLite
157+
* migration. Callers must migrate away from writing sessions.json directly.
158+
*/
154159
saveSessionStore,
155160
updateLastRoute,
161+
/**
162+
* @deprecated Use patchSessionEntry/upsertSessionEntry for writes. This
163+
* whole-store helper is kept only during the transition before SQLite
164+
* migration. Callers must migrate away from updating sessions.json directly.
165+
*/
156166
updateSessionStore,
157167
resolveSessionStoreEntry,
158168
} from "../config/sessions/store.js";

src/plugin-sdk/session-transcript-runtime.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,13 @@ export type SessionTranscriptTarget = SessionTranscriptIdentity & {
6060
targetKind: "active-session-file" | "runtime-session";
6161
};
6262

63+
/**
64+
* @deprecated Use SessionTranscriptTarget with `{ agentId, sessionKey,
65+
* sessionId }`. Active transcript file targets are transitional only and will
66+
* be removed with the SQLite session/transcript storage flip.
67+
*/
6368
export type SessionTranscriptLegacyFileTarget = SessionTranscriptTarget & {
64-
/**
65-
* Deprecated transitional file target for callers that still pass active
66-
* transcript files to plugin command handlers.
67-
*/
69+
/** Deprecated transitional file path for active transcript artifact callers. */
6870
sessionFile: string;
6971
};
7072

@@ -124,8 +126,9 @@ export async function resolveSessionTranscriptTarget(
124126
}
125127

126128
/**
127-
* Resolves and persists the current file-backed target for legacy plugin
128-
* command calls that still require `sessionFile`.
129+
* @deprecated Use resolveSessionTranscriptTarget with `{ agentId, sessionKey,
130+
* sessionId }`. This persists an active transcript file target only for legacy
131+
* plugin command calls that still require `sessionFile`.
129132
*/
130133
export async function resolveSessionTranscriptLegacyFileTarget(
131134
params: SessionTranscriptTargetParams,

0 commit comments

Comments
 (0)