MCPcopy Create free account
hub / github.com/apache/maka / buildSessionHeader

Function buildSessionHeader

packages/storage/src/session-store.ts:928–988  ·  view source on GitHub ↗
(
  workspaceRoot: string,
  input: CreateSessionInput,
  sessionId: string = randomUUID(),
  conversationCopy?: SessionConversationCopy,
)

Source from the content-addressed store, hash-verified

926}
927
928function buildSessionHeader(
929 workspaceRoot: string,
930 input: CreateSessionInput,
931 sessionId: string = randomUUID(),
932 conversationCopy?: SessionConversationCopy,
933): SessionHeader {
934 if (
935 input.projectId !== undefined &&
936 input.projectId !== null &&
937 (typeof input.projectId !== 'string' || input.projectId.length === 0)
938 ) {
939 throw new Error('Invalid project id');
940 }
941 const now = Date.now();
942 assertSafeSessionId(sessionId);
943 const name =
944 input.name === undefined ? DEFAULT_SESSION_NAME : normalizeRequiredSessionName(input.name);
945 const header: SessionHeader = {
946 id: sessionId,
947 workspaceRoot,
948 cwd: input.cwd,
949 ...(input.projectId !== undefined ? { projectId: input.projectId } : {}),
950 createdAt: now,
951 lastUsedAt: now,
952 name,
953 titleIsManual: false,
954 isFlagged: false,
955 labels: input.labels ?? [],
956 isArchived: false,
957 status: input.status ?? 'active',
958 ...(input.blockedReason ? { blockedReason: input.blockedReason } : {}),
959 statusUpdatedAt: now,
960 ...(input.parentSessionId ? { parentSessionId: input.parentSessionId } : {}),
961 ...(input.branchOfTurnId ? { branchOfTurnId: input.branchOfTurnId } : {}),
962 ...(input.subagentParent ? { subagentParent: input.subagentParent } : {}),
963 ...(input.subagentRuntime ? { subagentRuntime: input.subagentRuntime } : {}),
964 ...(input.subagentSpawn ? { subagentSpawn: input.subagentSpawn } : {}),
965 ...(input.subagentWorkspace ? { subagentWorkspace: input.subagentWorkspace } : {}),
966 ...(conversationCopy ? { conversationCopy } : {}),
967 ...(input.revisionRootSessionId ? { revisionRootSessionId: input.revisionRootSessionId } : {}),
968 ...(input.revisionParentSessionId
969 ? { revisionParentSessionId: input.revisionParentSessionId }
970 : {}),
971 ...(input.revisionOfTurnId ? { revisionOfTurnId: input.revisionOfTurnId } : {}),
972 ...(input.revisionIndex !== undefined ? { revisionIndex: input.revisionIndex } : {}),
973 ...(input.revisionState ? { revisionState: input.revisionState } : {}),
974 hasUnread: false,
975 backend: input.backend,
976 llmConnectionSlug: input.llmConnectionSlug,
977 connectionLocked: false,
978 model: input.model ?? 'default',
979 ...(input.toolProfile !== undefined ? { toolProfile: input.toolProfile } : {}),
980 permissionMode: input.permissionMode,
981 collaborationMode: input.collaborationMode ?? 'agent',
982 orchestrationMode: input.orchestrationMode ?? 'default',
983 ...(input.thinkingLevel !== undefined ? { thinkingLevel: input.thinkingLevel } : {}),
984 schemaVersion: 1,
985 };

Callers 5

createMethod · 0.85
createImportedSessionMethod · 0.85
createStableSessionMethod · 0.85
createSubagentMethod · 0.85

Calls 4

assertSafeSessionIdFunction · 0.70
nowMethod · 0.65

Tested by

no test coverage detected