feat: session source in session_meta and an Automated sidebar folder (#40)

Co-authored-by: Alice <alice@prismshadow.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Yaowei Zheng
2026-07-23 00:58:43 +08:00
committed by GitHub
parent e0bf1706b9
commit c380113e26
30 changed files with 1023 additions and 74 deletions
+10
View File
@@ -126,6 +126,8 @@ export interface CreateSessionOptions {
baseUrl?: string;
/** Internal use: this Session's depth in the subagent spawn chain (0 at the top level), used to cap spawn depth. */
subagentDepth?: number;
/** Session origin recorded in session_meta (absent = user-created); the subagent spawn site passes "subagent", callers driven by a scheduled task pass "schedule". */
source?: "subagent" | "schedule";
}
export interface ResumeSessionOptions {
@@ -298,6 +300,7 @@ export class Agent {
thinking_level: thinkingLevel ?? "default",
agent_state: this.state.stateDir,
workspace: workspaceDir,
...(opts.source !== undefined ? { source: opts.source } : {}),
},
llm: rt.llm,
environment: rt.environment,
@@ -444,6 +447,12 @@ export class Agent {
thinking_level: thinkingLevel ?? "default",
agent_state: this.state.stateDir,
workspace: workspaceDir,
// The origin carries over from the original session_meta (a resumed scheduled/subagent
// Session stays marked). The on-disk value is untrusted: only the exact known origins
// pass; junk written by a third party is dropped rather than cast through.
...(meta.source === "subagent" || meta.source === "schedule"
? { source: meta.source }
: {}),
},
llm: rt.llm,
environment: rt.environment,
@@ -573,6 +582,7 @@ export class Agent {
...childModel,
thinkingLevel: thinkingLevel ?? null,
subagentDepth: subagentDepth + 1,
source: "subagent",
});
// All child-session messages are tagged with an origin (the child Session id,
// prepended as one hop from outer to inner); the first turn forwards the
+2
View File
@@ -92,6 +92,8 @@ export interface SessionMetaPayload {
agent_state: string;
/** Absolute path to the Workspace. */
workspace: string;
/** Session origin: spawned by a subagent / triggered by a scheduled task; absent = user-created. */
source?: "subagent" | "schedule";
}
// ---------------------------------------------------------------------------