(opts: CreateSessionMetadataOptions)
| 72 | * ``` |
| 73 | */ |
| 74 | export function createSessionMetadata(opts: CreateSessionMetadataOptions): SessionMetadataResult { |
| 75 | const state: AgentState = { |
| 76 | controlledByUser: false, |
| 77 | }; |
| 78 | |
| 79 | const metadata: Metadata = { |
| 80 | path: process.cwd(), |
| 81 | host: os.hostname(), |
| 82 | version: packageJson.version, |
| 83 | os: os.platform(), |
| 84 | machineId: opts.machineId, |
| 85 | homeDir: os.homedir(), |
| 86 | happyHomeDir: configuration.happyHomeDir, |
| 87 | happyLibDir: projectPath(), |
| 88 | happyToolsDir: resolve(projectPath(), 'tools', 'unpacked'), |
| 89 | startedFromDaemon: opts.startedBy === 'daemon', |
| 90 | hostPid: process.pid, |
| 91 | startedBy: opts.startedBy || 'terminal', |
| 92 | lifecycleState: 'running', |
| 93 | lifecycleStateSince: Date.now(), |
| 94 | flavor: opts.flavor, |
| 95 | sandbox: opts.sandbox?.enabled ? opts.sandbox : null, |
| 96 | dangerouslySkipPermissions: opts.dangerouslySkipPermissions ?? null, |
| 97 | ...(opts.parentSessionId ? { parentSessionId: opts.parentSessionId } : {}), |
| 98 | ...(opts.forkedFromMessageId ? { forkedFromMessageId: opts.forkedFromMessageId } : {}), |
| 99 | }; |
| 100 | |
| 101 | return { state, metadata }; |
| 102 | } |
no test coverage detected